•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Shell Scripting section within the Software Development category of DaniWeb, a massive community of 456,432 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,619 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Shell Scripting advertiser: Programming Forums
Views: 3400 | Replies: 4
![]() |
•
•
Join Date: Jun 2007
Posts: 3
Reputation:
Rep Power: 0
Solved Threads: 0
I'm completely new to this and have fallen at the first hurdle.
I'm only playing so its not urgent.
Here is my little bit of code:
#!/bin/ksh
print Content-type: text/html
print
print '<pre style=font-family:Fixedsys>'
gtacl -c 'files $usvol1.ssdxl' |{
while read line ;do
print "${line%%=*}"
done
}
print '</pre>'
Don't worry too much about the gtacl command as that's machine specific but suffice to say the the files $usvol1.ssdxl has to be passed as is hence the single quotes (I think!).
What I'd like to do is change the code such that the $usvol1.ssdxl gets passed in as a parameter on the command line so it has to become:
gtacl -c "files $1"
The $1 gets expanded to the value of the parameter but then because the expanded value starts with a $ KSH tries to interpret as something other than a text string.
I've tried hard, but how does one get around this?
Cheers
Don
I'm only playing so its not urgent.
Here is my little bit of code:
#!/bin/ksh
print Content-type: text/html
print '<pre style=font-family:Fixedsys>'
gtacl -c 'files $usvol1.ssdxl' |{
while read line ;do
print "${line%%=*}"
done
}
print '</pre>'
Don't worry too much about the gtacl command as that's machine specific but suffice to say the the files $usvol1.ssdxl has to be passed as is hence the single quotes (I think!).
What I'd like to do is change the code such that the $usvol1.ssdxl gets passed in as a parameter on the command line so it has to become:
gtacl -c "files $1"
The $1 gets expanded to the value of the parameter but then because the expanded value starts with a $ KSH tries to interpret as something other than a text string.
I've tried hard, but how does one get around this?
Cheers
Don
Works for me, don't you want a command like this?
$ f='$usvol1.ssdxl' $ echo "gtacl -c 'files $f'" gtacl -c 'files $usvol1.ssdxl'
•
•
Join Date: Jun 2007
Posts: 3
Reputation:
Rep Power: 0
Solved Threads: 0
Hi radoulov,
Thanks but, still struggling I'm afraid.
Here is new test script (my file is called cgic)
#!/bin/ksh
echo "1 is 'files $1'"
a=$1
echo "a is 'files $a'"
b="$1"
echo "b is 'files $b'"
c='$1'
echo "c is 'files $c'"
From command line invoke thus:
./cgic This.is.a.test.string
Results:
1 is 'files This.is.a.test.string'
a is 'files This.is.a.test.string'
b is 'files This.is.a.test.string'
c is 'files $1'
From command line invoke thus:
./cgic $usvol1.ssdxl
Results:
1 is 'files .ssdxl'
a is 'files .ssdxl'
b is 'files .ssdxl'
c is 'files $1'
Thanks but, still struggling I'm afraid.
Here is new test script (my file is called cgic)
#!/bin/ksh
echo "1 is 'files $1'"
a=$1
echo "a is 'files $a'"
b="$1"
echo "b is 'files $b'"
c='$1'
echo "c is 'files $c'"
From command line invoke thus:
./cgic This.is.a.test.string
Results:
1 is 'files This.is.a.test.string'
a is 'files This.is.a.test.string'
b is 'files This.is.a.test.string'
c is 'files $1'
From command line invoke thus:
./cgic $usvol1.ssdxl
Results:
1 is 'files .ssdxl'
a is 'files .ssdxl'
b is 'files .ssdxl'
c is 'files $1'
Last edited by TheDonDon : Jun 15th, 2007 at 4:15 am.
You have to escape the $ sign:
$ cat script #!/bin/ksh echo "1 is 'files $1'" a=$1 echo "a is 'files $a'" b="$1" echo "b is 'files $b'" c='$1' echo "c is 'files $c'" $ ./script '$usvol1.ssdxl' 1 is 'files $usvol1.ssdxl' a is 'files $usvol1.ssdxl' b is 'files $usvol1.ssdxl' c is 'files $1' $ ./script \$usvol1.ssdxl 1 is 'files $usvol1.ssdxl' a is 'files $usvol1.ssdxl' b is 'files $usvol1.ssdxl' c is 'files $1'
![]() |
•
•
•
•
•
•
•
•
DaniWeb Shell Scripting Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Similar Threads
- passing parameters in bat file (Visual Basic 4 / 5 / 6)
- passing parameters to a page (JavaScript / DHTML / AJAX)
- Passing Variables/Parameters - By Ref/Value? (Computer Science and Software Design)
- Recursion (C++)
- using a varible from main method (Java)
Other Threads in the Shell Scripting Forum
- Previous Thread: script to email new ip
- Next Thread: rm command


Linear Mode