Passing a variable to #BSUB -n in a LSF file | Unix Linux Forums | Shell Programming and Scripting

  Go Back    


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Passing a variable to #BSUB -n in a LSF file

Shell Programming and Scripting


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 08-15-2011
lrayo lrayo is offline
Registered User
 
Join Date: Aug 2011
Last Activity: 22 August 2011, 6:26 AM EDT
Posts: 3
Thanks: 1
Thanked 0 Times in 0 Posts
Bug Passing a variable to #BSUB -n in a LSF file

Hi There!

I'm writing this LSF script to make it easier to send jobs to a cluster when varying certain parameters. At one point I'd like to do something like:

set NPROC = 10

and later on call BSUB using something like:

#BSUB -n $NPROC

unfortunately for me, this throws an error:

Bad argument for option -n. Job not submitted.

Anyone with an idea on how to pass BSUB a variable? With this example it sounds sort of roundabout, but sometimes you want to do some arithmetic with $NPROC before passing it to #BSUB and then being able to do it this way may be something very useful.

Thanks!

---------- Post updated at 06:01 PM ---------- Previous update was at 05:57 PM ----------

Sorry, I read the post back and I wanted to make sure the problem is clear, this works straight away:

#BSUB -n 10

This doesn't work

set NPROC = 10
#BSUB -n $NPROC

Thanks
Sponsored Links
    #2  
Old 08-15-2011
Corona688 Corona688 is offline Forum Staff  
Mead Rotor
 
Join Date: Aug 2005
Last Activity: 28 November 2014, 4:08 PM EST
Location: Saskatchewan
Posts: 19,944
Thanks: 848
Thanked 3,422 Times in 3,207 Posts
What is your system? What is your shell?

Most shells don't allow whitespace wherever you want like that.


Code:
VAR = "stuff"
VAR="stuff"

The Following User Says Thank You to Corona688 For This Useful Post:
lrayo (08-16-2011)
Sponsored Links
    #3  
Old 08-16-2011
lrayo lrayo is offline
Registered User
 
Join Date: Aug 2011
Last Activity: 22 August 2011, 6:26 AM EDT
Posts: 3
Thanks: 1
Thanked 0 Times in 0 Posts
Thanks for your help Corona688, I'm sorry, using -tcsh on RedHat.

I think the problem is more related with #BSUB itself, because in some other part of the code I have things like:

#! bin/tcsh -f

set VAR_1 = 5
set VAR_1 = 10

@ sum = VAR_1 + VAR_2

and that works alright

---------- Post updated 08-16-11 at 10:05 AM ---------- Previous update was 08-15-11 at 07:32 PM ----------

I can't post links yet, but if you google bsub you'll find its man page straight away.

It can accept commands through the command line like:

>bsub -n 10

or through standard input doing

>bsub < myscript.lsf

they way bsub reads commands from standard input is by including the keyword #BSUB on the file, so you would have to write on it:

#! /bin/tcsh -f
#BSUB -n 10

I think that the problem is that when I write inside myfile.lsf:

#! /bin/tcsh -f
set NPROC = 10
#BSUB -n $NPROC

The variable $NPROC is being read as a string on standard input, instead of as a variable.

anyone with an idea of how to solve this? I'm running red had linux and TC shell

Thanks!
    #4  
Old 08-16-2011
Corona688 Corona688 is offline Forum Staff  
Mead Rotor
 
Join Date: Aug 2005
Last Activity: 28 November 2014, 4:08 PM EST
Location: Saskatchewan
Posts: 19,944
Thanks: 848
Thanked 3,422 Times in 3,207 Posts
There are lots of very good reasons not to program in TCSH. If you're not being forced to use it, I'd suggest learning the Bourne shell.

But meanwhile, this syntax works both in BASH and TCSH:

Code:
./command <<EOF
stuff to feed into command's stdin
This can include $VARIABLES and `commands`
EOF

The final EOF must be at the beginning of the line with NO spaces in front.

Last edited by Corona688; 08-16-2011 at 03:32 PM..
Sponsored Links
    #5  
Old 08-17-2011
lrayo lrayo is offline
Registered User
 
Join Date: Aug 2011
Last Activity: 22 August 2011, 6:26 AM EDT
Posts: 3
Thanks: 1
Thanked 0 Times in 0 Posts
Bug

Thanks again.

I do not think I have understood your suggestion properly enough to apply it.

Should I do something like:

>set NPROC = 10
>bsub <<$NPROC < base.lsf

and then in base.lsf just do something like:


Code:
#! /bin/tcsh

#BSUB -n $NPROC

That doesn't even make sense to me. If you could please be more explicit on your suggestion so I can understand it that would be very helpful. Thanks!
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Node selection with bsub mancino Shell Programming and Scripting 0 08-03-2011 06:31 AM
Writing a script to work sequentially with bsub silky UNIX for Dummies Questions & Answers 1 11-21-2008 05:26 AM
Passing output to variable instead of file Furqan_79 Shell Programming and Scripting 1 05-27-2008 07:17 AM
passing a variable inside a variable to a function KingVikram UNIX for Dummies Questions & Answers 2 01-14-2008 08:28 PM
passing unix variable to sqlplus without a file name sakthi.abdullah UNIX for Advanced & Expert Users 3 12-12-2006 06:35 AM



All times are GMT -4. The time now is 09:10 PM.