script crashing with error message: "couldn't execute bsub" - linux

our IT updated LSF farm/OS and now our Tcl script does not work anymore: within our script we executing "bsub -q reg -R "rh70" csh_file" in a loop.
for unknown reason, at some point during the loop 'on 5th element' we are getting following error message: "couldn't execute bsub" as if command is unkown...
we don't understand why starting at some point in the loop the same command does not work anymore... can you help me understand this issue?
Thanks,
Chris
sript is supposed to work without any issue within foreach loop (as it was the case before IT update LSF/OS).

Related

No Error from Script for Non-Existent File

I have a shell script that reads a text file and uses its content. So far so good. But now I'm trying to make the script exit if the file is not found. The script looks like this
#!/bin/bash
function errorcatcher() {
errorcode=$?
echo "ERROR CODE : ${errorcode}"
exit ${errorcode}
}
trap errorcatcher ERR
MYFILE=$1
IFS='|'
while read line; do
echo ${line}
done < ${MYFILE}
echo "Execution complete"
And I run the script as
sh myscript.sh /home/mydir/ABC.txt
and it works fine. But if I try this
sh myscript.sh /home/mydir/nonexisting.file
I get
myscript.sh: line 17: /home/mydir/nonexisting.file: No such file or directory
Execution complete
Function errorcatcher does not get invoked and instead of exiting with an error code, the execution continues and I get the line Execution complete even though the file in question doesn't exist. My guess is no error is generated here, so I added this line before reading the text file
ls ${MYFILE}
The errorcatcher gets invoked this time. But if I try
sh myscript.sh /home/mydir/ABC.tx
Instead of existing file ABC.txt, I pass its incomplete name ABC.tx and again, the errorcatcher function is not invoked and the script completes successfully (Execution complete gets echoed).
Could someone help me with this? I'm curious as to why errorcatcher doesn't get invoked
for a non existing file without ls
for incomplete file name (ABC.tx) with ls
Function errorcatcher does not get invoked …
Indeed, with an error in the redirection of a loop like
while read line; do
…
done < ${MYFILE}
the ERR trap is not invoked. You have discovered an undocumented exception in the implementation of the trap command, or, if you prefer, a bug.
You can evade that by adding an additional test of the redirection before the while, e. g. the line
<$MYFILE
on its own will invoke the error trap.

os.system(cmd) call fails with redirection operator

My Python 3.7.1 script generates a fasta file called
pRNA.sites.fasta
Within the same script, I call following system command:
cmd = "weblogo -A DNA < pRNA.sites.fasta > OUT.eps"
os.system(cmd)
print(cmd) #for debugging
I am getting the following error message and debugging message on the command line.
Error: Please provide a multiple sequence alignment
weblogo -A DNA < pRNA.sites.fasta > OUT.eps
"OUT.eps" file is generated but it's emtpy. On the other hand, if I run the following 'weblogo' command from the command line, It works just find. I get proper OUT.eps file.
$ weblogo -A DNA<pRNA.sites.fasta>OUT.eps
I am guessing my syntax for os.system call is wrong. Can you tell me what is wrong with it? Thanks.
Never mind. It turned out to be that I was not closing my file, "pRNA.sites.fasta" before I make system call that uses this file.

Strange (internal?) default constructor error message using chdir in Perl 6 REPL

I'm facing the following error:
&*chdir('/home/account')
Failed to change the working directory to '/home/account': Default constructor for 'IO::Path' only takes named arguments
What do I need to change to overcome this error?
(I am using perl6 version 2013.12 Ubuntu 14.04)
2013.12 is 4.5 years old. I would not recommend learning Perl 6 with that version. Please try to get a more recent version: the documentation for it will be more up to date, and it will be one, if not 2 orders of magnitude faster.
Also, why not use chdir instead of &*chdir? The latter being something that is relic from ancient times, afaik. If you just chdir, you get:
$ perl6 -e 'chdir("/home/account")'
Failed to change the working directory to '/home/account': does not exist
Which is definitely already much more understandable.
Secondly, if a chdir fails, it returns a Failure. When a Failure is sunk (aka being called in "void" context in Perl 5 terms), it will throw the Exception it contains. Which is what you just saw.
chdir returns an IO::Path object if successful, which is True in a Boolean context such as an if or a ternary:
$ perl6 -e 'say chdir("/home/account") ?? "Yeah!" !! "Alas"'
Alas
But in most cases where you want to do something inside a directory, you will want to use indir( $path, { code to execute } ). That will ensure that no code will be executed in that directory except for the code given as the second parameter.

'Bad substitution' error in bash script

I keep getting a 'bad substitution' error in my bash script at the point ${basename $option} where '$option' is input later in the script, does anyone know how to fix it?
function findByExtension {
strip=${basename $option}
extension="${strip##*.}"
}
I have also included '#!/bin/bash' at the start of the script.
You want to perform command substitution there, not parameter substitution.
strip="$(basename "$option")"

How do I make a Perl script stop when running Matlab code fails?

I would like to make the Perl script run some Matlab code, then wait, then run another Matlab code in Linux. If the Matlab code fails, then it should give an error message. The Perl script below would run through even when Matlab code 1 or 2 has an error. How do I make the Perl script stop and give an error message when the Matlab codes fails?
print("run Matlab code 1!\n");
`matlab -nodisplay -r myfile1`;
print("run Matlab code 2!\n");
`matlab -nodisplay -r myfile2`;
print("End!\n");
First, store the return code of the command you are running:
my $returnCode = system("matlab -nodisplay -r myfile1");
Then, before you move to the next step, make sure the return code is 0 (or whatever indicates success in your case):
if ($returnCode != 0) {
die "Command did not finish successfully.";
}
Just determine what is a valid return code and tell the script to die in any other case.

Resources