- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Simple scripting issue that's got me stumped r...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-19-2005 08:49 AM
тАО04-19-2005 08:49 AM
works fine on my local server
But if I set a variable equal to the command
export CMD1="/usr/sbin/swlist | grep | sort | tail -1"
and then "$CMD1", it's not recognizing the pipe symbols and I get errors about "software | not found" and "sofware grep not found" etc.
But a "remsh xxxxxxx $CMD1" works fine.
I'm trying to get a script that will issue the same command on both the local server and a list of remote servers and I'm stumped why it's being treated differently on the local server.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-19-2005 08:53 AM
тАО04-19-2005 08:53 AM
Re: Simple scripting issue that's got me stumped right now
try:
export CMD1='/usr/sbin/swlist | grep | sort | tail -1'
(' instead of ")
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-19-2005 08:54 AM
тАО04-19-2005 08:54 AM
Re: Simple scripting issue that's got me stumped right now
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-19-2005 08:57 AM
тАО04-19-2005 08:57 AM
Re: Simple scripting issue that's got me stumped right now
Single quote didn't help, but:
export CMD1="/usr/sbin/swlist | grep | sort | tail -1"
sh $CMD1
worked fine.
that's why it works with "remsh", it's just like running it with "sh".
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-19-2005 09:01 AM
тАО04-19-2005 09:01 AM
Solutiontry this:
CMD1="/usr/sbin/swlist | grep | sort | tail -1"
eval $CMD1
the problem is that you must force the shell to eval the line twice, the first one to substitute the variable, second one to exec the pipe. Is like:
a="echo b=test"
eval $a
or
eval $(resize) in a xterm
hope it helps
- Tags:
- eval
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-19-2005 09:10 AM
тАО04-19-2005 09:10 AM
Re: Simple scripting issue that's got me stumped right now
set CMD="ls -al" and run $CMD and it works fine.
- Biswajit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-19-2005 09:19 AM
тАО04-19-2005 09:19 AM
Re: Simple scripting issue that's got me stumped right now
Single quotes didn't help, "sh $CMD1" kept giving me "execute permission denied" but "eval $CMD1" worked great.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-22-2005 11:48 AM
тАО04-22-2005 11:48 AM
Re: Simple scripting issue that's got me stumped right now
alias CMD1="/usr/sbin/swlist | grep | sort | tail -1"
CMD1
- Biswajit
- Tags:
- alias