- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Getting remote variables more efficiently
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
тАО07-12-2010 08:15 AM
тАО07-12-2010 08:15 AM
I have a script that has to get variables remotely. Rather than having the script login to the remote server 3 separate times, is there a faster way to get each variable?
CODE
--------------------------------------------------------------------
##Server comes from input or list##
CHKINSTALL=`ssh server "swlist | grep -i program" | grep -v Running | awk '{print $1}'`
CHKVERSION=`ssh server "swlist | grep -i program" | grep -v Running | awk '{print $2}'`
CFEPROCESS=`ssh server "ps -ef | grep -i program > /dev/null ; echo $?" | grep -v -e grep -e Running`
Solved! Go to Solution.
- Tags:
- variable
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-12-2010 08:45 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-12-2010 06:23 PM
тАО07-12-2010 06:23 PM
Re: Getting remote variables more efficiently
SWLISTOUT=$(ssh server /usr/sbin/swlist)
CHKINSTALL=$(echo "$SWLISTOUT" | grep -i program | grep -v Running | awk '{print $1}')
CHKVERSION=$(echo "$SWLISTOUT" | grep -i program | grep -v Running | awk '{print $2}')
Grave accents `` are obsolete and deprecated in the man pages. Use $(command...) instead.
ps|grep is full of mistakes. Use ps to locate programs by name using the UNIX95 variable to activate -C and -o features:
CFEPROCESS=$(ssh server UNIX95=1 ps -C program -o pid= -oargs=)
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-16-2010 11:27 AM
тАО07-16-2010 11:27 AM
Re: Getting remote variables more efficiently
-------------------------------------------
CFEPROCESS=$(ssh server UNIX95=1 ps -C program -o pid= -oargs=
-------------------------------------------
Bill, I've never used the UNIX95 command. I noticed the flags you used for the pid and other arguments. Is the "-o pid=" required?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-16-2010 11:44 AM
тАО07-16-2010 11:44 AM
Re: Getting remote variables more efficiently
Bill's UNIX95 argument is required for values on his recommended ps command.
Without setting the variable, you won't get the data.
First time I saw this, I got all excited and set UNIX95 in my /etc/profile . That was a bad idea, as it broke several things on the system.
You need UNIX95 for the command Bill recommends.
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-16-2010 11:55 AM
тАО07-16-2010 11:55 AM
Re: Getting remote variables more efficiently
UNIX95 is a variable, not a command. It is an underutilized feature of the shell that you can temporarily assign a variable for the duration of the command by making the assignment in front of a command. UNIX95 (when defined) enables 3 VERY useful options:
-C exact-process-name
-H show hierarchy of parents and children
-o make your own customized ps command
-C is the only way to stop grep failures -- let ps find the process in the kernel's process table. So ps -C sh and ps -C ksh will get exact matches.
-o
Bill Hassell, sysadmin