|
|
|
|
|
|
| Author |
Message |
Rakesh Sharma *nix forums beginner
Joined: 28 Feb 2005
Posts: 36
|
Posted: Tue Feb 15, 2005 9:54 am Post subject:
Re: ksh parsing question
|
|
|
"Tom Shippee" <t.s.shippee@snet.net> wrote in message news:
| Quote: |
I am writing a program to read a text file, parse it, and run commands
based on one of the fields. The "single" commands work ok, but ksh appears
not to parse the variable line when it is executed. If there is a pipe in
the string the command gets an error. For example, below the first sequence
fails, but the other two work ok. Any suggestions on how to get ksh to
parse the text string before executing?
|
eval does exactly that, it parses your string one more time before executing.
eval "$CMD" |
|
| Back to top |
|
 |
TB *nix forums Guru Wannabe
Joined: 14 Mar 2005
Posts: 241
|
Posted: Tue Feb 15, 2005 3:28 am Post subject:
Re: ksh parsing question
|
|
|
Instead of using the double quotes ( " ) use the grave accent ( ` ),
not the single quote, but the ` that is usually with the ~ on your
keyboard.
T. |
|
| Back to top |
|
 |
Tom Shippee *nix forums beginner
Joined: 29 Mar 2005
Posts: 2
|
Posted: Tue Feb 15, 2005 2:50 am Post subject:
ksh parsing question
|
|
|
I am writing a program to read a text file, parse it, and run commands
based on one of the fields. The "single" commands work ok, but ksh appears
not to parse the variable line when it is executed. If there is a pipe in
the string the command gets an error. For example, below the first sequence
fails, but the other two work ok. Any suggestions on how to get ksh to
parse the text string before executing?
( I am able to get around this by creating a temporary file with the CMD
string then executing it. I also tried creating an "alias" then executing
that. This works ok, but it seems like there should be a more elegant way to
manage this little problem. The goal is to have a script that wil work on
AIX, Solaris and HPUX. Any suggestion appreciated. )
#!/bin/ksh
#
#
# Does Not Work
#
CMD="netstat -an | grep LIST"
echo "Command1: $CMD"
$CMD
#
# Works OK
#
CMD="netstat -an"
$CMD
#
# Works OK
#
netstat -an | grep LIST
Error OutPut:
$ /tmp/temp1.sh
Command1: netstat -an | grep LIST
netstat: extra arguments
usage: netstat [-anv] [-f address_family]
netstat [-g | -p | -s] [-n] [-f address_family] [-P protocol]
netstat -m
netstat -i [-I interface] [-an] [-f address_family] [interval]
netstat -r [-anv] [-f address_family]
netstat -M [-ns] [-f address_family]
netstat -D [-I interface] [-f address_family] |
|
| Back to top |
|
 |
Google
|
|
| Back to top |
|
 |
|
|
The time now is Thu Jan 08, 2009 11:14 pm | All times are GMT
|
|
Debt Consolidation | Loans | Just Holden Commodores | Credit Counseling | Credit Cards
|
|
Copyright © 2004-2005 DeniX Solutions SRL
|
|
|
|
Other DeniX Solutions sites:
Unix/Linux blog |
electronics forum |
medicine forum |
science forum |
|
|
Privacy Policy
|
Powered by phpBB © 2001, 2005 phpBB Group
|
|