LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-15-2013, 01:21 AM   #1
chrisb2244
LQ Newbie
 
Registered: Oct 2013
Posts: 2

Rep: Reputation: Disabled
Post Passing script options/arguments out of a subshell to a .sh file set of commands


Hi,

I am wondering if it is possible to use command line arguments to make small modifications to a file.sh that I have and use to submit jobs to a computing cluster using qsub, or if failing this I can write a separate script to generate a suitable file to submit.

Currently, I have something like
Code:
#!/bin/bash
showopts () {
while getopts ":q:n:j:" optname
do
case "$optname" in

"q")
$OPTARG < queueType
;;

"n")
$OPTARG < jobName
;;

"j")
$OPTARG < progToExecute
;;

":")
echo "No argument value for option $OPTARG"
;;
*)
echo "Unknown error while processing options"
;;

esac
done

return $OPTIND
}


PROGTOEXECUTE=$progToExecute
echo "$PROGTOEXECUTE"
QUEUETYPE=$jobName
echo "$QUEUETYPE"
JOBname=$queueType
echo "$JOBname"

#$ -S /bin/bash
#$ -cwd
#$ -N $JOBname
#$ -q $QUEUETYPE
#$ -M email.address
#$ -j no
#$ -l h_vmem=2.5g
#$ -l virtual_free=1.5g
#$ -m abe

$PROGTOEXECUTE > statusLog$JOB_NAME
The sh file that I normally submit is the section at the bottom - starting at #$ -S /bin/bash and running to the end of the code section.
The earlier part of the code is my attempt to move the information sent to the script out of a subshell, but clearly I have misunderstood what I've been reading. The echo commands next to where I'm trying to write assignments are just to test their (in)efficacy, and would be removed from a working script/.sh file. Also, the $JOB_NAME variable in the last line is set to be whatever follows the "#$ -N " part.

In case it is unclear, I'd hope to be able to write something like:

>> qsub file.sh -q short -n name -j "tar -xzf tarfile.tar.gz"
as a simple example.

Any help would be much appreciated.
 
Old 10-15-2013, 07:20 AM   #2
elucches
Member
 
Registered: Jan 2011
Posts: 108

Rep: Reputation: 11
Hello,
I don't know how to use getopts, but can't you use positional parameters (http://tldp.org/LDP/abs/html/othertypesv.html)?
Best regards,
Esteban
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Bash Script passing arguments dimitriauxio Linux - Newbie 8 09-16-2013 09:19 AM
Passing arguments to shell script like perl script get-opts somupl86 Linux - Newbie 2 12-02-2010 11:14 PM
[SOLVED] passing commands as arguments to functions in bash script mastahyeti Linux - General 3 05-31-2010 06:19 PM
Passing command line arguments through getopts and long options neville310 Programming 3 04-16-2007 06:38 AM
Passing arguments to a shell script subu_s Programming 3 09-02-2005 05:13 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:49 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration