Welcome to the most active Linux Forum on the web.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 10-15-2013, 01:21 AM   #1
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


I am wondering if it is possible to use command line arguments to make small modifications to a 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
showopts () {
while getopts ":q:n:j:" optname
case "$optname" in

$OPTARG < queueType

$OPTARG < jobName

$OPTARG < progToExecute

echo "No argument value for option $OPTARG"
echo "Unknown error while processing options"


return $OPTIND

echo "$JOBname"

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

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 -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
Registered: Jan 2011
Posts: 93

Rep: Reputation: 9
I don't know how to use getopts, but can't you use positional parameters (
Best regards,


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

All times are GMT -5. The time now is 05:04 PM.

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