Results 1 to 4 of 4
Thread: bash, command line arguments
|
Enjoy an ad free experience by logging in. Not a member yet? Register.
|
|
-
08-21-2013 #1
- Join Date
- Dec 2010
- Posts
- 122
bash, command line arguments
Code:#/bin/bash # # example: ./configure input-file, SSID, IP, device-name, gateway, frequency, output-file # FILE=${1} SSID=${2} IP=${3} DEVICE=${4} GATEWAY=${5} FREQUENCY="" OUTPUT=${6} if [[ ${#} -eq 8 ]]; then # { FREQUENCY=${6} OUTPUT=${7} fi sed -e "s/\(empty-ssid\).*/${SSID}/g" \ -e "s/192\.168\.1\.20$/${IP}/g" \ -e "s/\(NanoBridge M.\)/${DEVICE}/g" \ -e "s/empty-frequency/${FREQUENCY}/g" \ -e "s/\(192\.168\.1\.1\).*/${GATEWAY}/g" ${FILE} > ${OUTPUT} #END#
-
08-22-2013 #2
- Join Date
- Aug 2012
- Posts
- 31
I just ran your script (excluding the sed line) and it seems to work.
Are you sure you're actually putting 8 arguments in the line? Your example only shows 7.
Also, I'm not sure you intend to separate the arguments with commas
-
08-22-2013 #3
- Join Date
- Nov 2012
- Posts
- 335
hi,
Code:$ myFunc(){ one="$1" two="$2" three="$3" four="$4" five="$5" ; (($#==8)) && six="$6" seven="$7" || seven="$6"; echo "seven = $seven";} $ myFunc 1 2 3 4 5 6 7 8 seven = 7 $ myFunc 1 2 3 4 5 6 7 seven = 6
-
08-22-2013 #4
- Join Date
- Jan 2005
- Location
- Saint Paul, MN
- Posts
- 818
How many different threads do you need for the same program???? This is at least the third one for this program.