Sponsored Content
Top Forums Shell Programming and Scripting Help with Passing argument and testing Post 302399538 by zeebala1981 on Sunday 28th of February 2010 08:37:06 PM
Old 02-28-2010
MySQL

Quote:
Originally Posted by durden_tyler
Something like this ?

Code:
$ 
$ cat -n myscript.sh
     1  #!/bin/bash
     2  if [ $# != 1 ]
     3  then
     4    echo "You must pass exactly one argument to this script!"
     5    exit 1
     6  fi
     7  if [[ $1 != 1 && $1 != 11 ]]
     8  then
     9    echo "The input parameter must be 1 or 11!"
    10    exit 2
    11  fi
    12  echo "You have passed 1 or 11 to this script!"
    13
$ 
$ ./myscript.sh
You must pass exactly one argument to this script!
$ 
$ ./myscript.sh 10 20 30
You must pass exactly one argument to this script!
$ 
$ ./myscript.sh 99
The input parameter must be 1 or 11!
$ 
$ ./myscript.sh 1
You have passed 1 or 11 to this script!
$ 
$ ./myscript.sh 11
You have passed 1 or 11 to this script!
$ 
$

tyler_durden

tyler

Thanks for the timely help its really working.Could you explain the following line alone please

if [[ $1 != 1 && $1 != 11 ]]
 

10 More Discussions You Might Find Interesting

1. Programming

Thread Argument Passing

#include <stdio.h> #include <pthread.h> #define NUM_THREADS 4 /* function to be executed by the new thread*/ void *PrintHello(void * threadid) { printf("\n %3d:Hello World!\n",threadid); pthread_exit(NULL); } int main(int argc, char * argv) { int *taskids; int... (2 Replies)
Discussion started by: narom
2 Replies

2. Shell Programming and Scripting

passing argument into awk

i'm trying to pass a numerical argument with function xyz to print specfic lines of filename, but my 'awk' syntax is incorrect. ie xyx 3 (prints the 3rd line, separated by ':' of filename) function xyz() { arg1=$1 cat filename | awk -F: -v x=$arg1 '{print $x}' } any ideas? (4 Replies)
Discussion started by: prkfriryce
4 Replies

3. Shell Programming and Scripting

passing Argument

Hi All, i have script like below.. echo "1) first option" echo "" echo "2) second option" echo "" echo "*) please enter the correct option" read select case $select in 1) echo "first option selected" ;; 2) echo "second option selected" ;; *) echo "please enter the correct... (4 Replies)
Discussion started by: Shahul
4 Replies

4. Shell Programming and Scripting

passing an option as an argument!

Hi Folks I have got to the point where I can specify the arguments but how to pass an option is still mystery to me. Example: temp.csh a b c d set temp1 = $argv set temp2 = $argv set temp3 = $argv echo $temp1 a echo $temp2 b echo $temp3 c d I WANT: temp.csh a b c d -S 1 set temp1... (2 Replies)
Discussion started by: dixits
2 Replies

5. Shell Programming and Scripting

passing argument in script?

hi, I want to implement some function to perform following task if ; then $TEXT = "Data_0" else $TEXT = $1 fi if ; then $Lines = 45 else $Lines = $2 fi Kindly suggest, thanks (11 Replies)
Discussion started by: nrjrasaxena
11 Replies

6. Shell Programming and Scripting

Passing user argument

Hi all: I'm trying to pass an argument to a command but it's being difficult. #!/bin/bash set -xv if ; then echo "More than 1 argument entered" echo "Please enter a month using 3 character names, ie, Jan, Mar, Apr, Dec" && exit 1 fi if ; then echo "Please enter a month using... (2 Replies)
Discussion started by: raggmopp
2 Replies

7. Shell Programming and Scripting

Help with passing argument

Hi, I have a script that is scheduled with cron and runs every night. The cron part looks like this: 00 20 * * 0,1,2,3,4,5,6 /usr/local/bin/BACKUP TBTARM HOT DELETE My issue is with the 3rd parameter. Somewhere in the script, i want to tell the script to delete some files if the 3rd... (7 Replies)
Discussion started by: dollypee
7 Replies

8. Shell Programming and Scripting

Argument passing

How to pass the alphabet character as a argument in case and in if block? ex: c=$1 if a-z ]] then echo "alphabet" case $1 in a-z) echo "the value is a alphabet" edit by bakunin: please use CODE-tags. We REALLY mean it. (9 Replies)
Discussion started by: Roozo
9 Replies

9. Shell Programming and Scripting

Passing argument not retrieving.

Hi I have a script which am trying to pass an argument which am trying to call using $1 but its not taking the value inside the if loop as it showing the error as if: Empty if.. Any help on this will be helpful. #!/usr/bin/csh echo $1 if ('$1' == "pp") then echo "Printing $1" endif (4 Replies)
Discussion started by: rogerben
4 Replies

10. UNIX for Beginners Questions & Answers

Passing a second argument

I am trying to pass a second argument like so: if ] then export ARG2=$2 else message "Second argument not specified: USAGE - $PROGRAM_NAME ARG1 ARG2" checkerror -e 2 -m "Please specify if it is a history or weekly (H or W) extract in the 2nd argument" fi however, it always goes... (4 Replies)
Discussion started by: MIA651
4 Replies
vbbatch(1)							 The VoxBo Manual							vbbatch(1)

NAME
vbbatch - run a command line multiple times with variable substitution SYNOPSIS
vbbatch <flag> ... DESCRIPTION
vbbatch is part of the VoxBo suite of tools for brain image analysis. vbbatch allows you to run a command multiple times with some variable substitutions (typically replacing the token FILE with each of a set of filenames). The commands are then run in parallel. If a VoxBo cluster is detected, the jobs will be submitted to the cluster. OPTIONS
EXAMPLES
To run myscript.sh on all your subjects' Anatomy directories: vbbatch -c "myscript.sh FILE" study*/sub*/Anatomy -r To run myperms.sh 1000 times at low priority, with different output files: vbbatch -c "myperms.sh results_IND.nii.gz" -d 1000 -r -p xnice AVAILABILITY
Pre-built VoxBo binaries are available for Linux, OSX, and Cygwin, and via the NeuroDebian project (neuro.debian.net) for Debian deriva- tives. CAVEATS
VoxBo is provided with no warranty whatsoever. AUTHOR
For an historical roster of the VoxBo development team, visit www.voxbo.org. SEE ALSO
For detailed help on any VoxBo command-line program, run it with no arguments. For graphical programs, use the -h flag. For more help with VoxBo, for information about the mailing list, or to report bugs, visit the web site at www.voxbo.org. For information about file format support in VoxBo, see voxbo-fileformats(7). For general information about VoxBo, see voxbo(7). VoxBo January, 2011 (v1.8.5) vbbatch(1)
All times are GMT -4. The time now is 11:22 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy