- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: running a command without a prefix
Operating System - HP-UX
1753506
Members
5019
Online
108794
Solutions
Forums
Categories
Company
Local Language
юдл
back
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
юдл
back
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
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Go to solution
Topic Options
- 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-11-2008 06:56 AM
тАО07-11-2008 06:56 AM
Hello all,
I have created a script that runs several functions to gather system information on a remote host ....
I have to program the script to check for local host or remote host and if the server is a remote server then a prefix (ssh command) variable is set:
for SERVER_NAME in ${SERVER_LIST}
do
if [[ "${SERVER_NAME}" = "${HOSTNAME}" ]]
then
export PREFIX=""
echo " - Generating report for : ${SERVER_NAME}"
generate_report > ${REPORT_DIR}/${SERVER_NAME}.html
else
export PREFIX="ssh -l ${USER} ${SERVER_NAME}"
echo "\n - Testing connectivity to server: ${SERVER_NAME}"
if ping -c 1 -w 1 ${SERVER_NAME} >/dev/null 2>&1
then
echo " - ping test ok for server : ${SERVER_NAME}"
${PREFIX} 'echo' >/dev/null 2>&1
if [ "$?" -eq "0" ]
then
echo " - rsh test ok for sever : ${SERVER_NAME}"
echo " - Generating report for : ${SERVER_NAME}"
generate_report > ${REPORT_DIR}/${SERVER_NAME}.html
else
echo " - ERROR: Unable to ssh to : ${SERVER_NAME}"
fi
else
echo " - ERROR: Unable to ping : ${SERVER_NAME}"
fi
fi
done
the issue I have is when the script is run on the local host the ${PREFIX} variable is causing me issues:
${PREFIX} 'if [ -f /usr/bin/lparstat ]
then
LANG=C uname -Ls | read junk partition_number partition_name
echo "Partition Number : ${partition_number}"
echo "Partition Name : ${partition_name}"
fi'
its obvious that there is a problem running the commands with the '<script>'
is there anyway around this otherwise I will have to create another script to be run if the server is the local host.
Thanks in advance and I hope this isnt too confusing.
NB the example about is one of many functions run in the script.
Chris.
I have created a script that runs several functions to gather system information on a remote host ....
I have to program the script to check for local host or remote host and if the server is a remote server then a prefix (ssh command) variable is set:
for SERVER_NAME in ${SERVER_LIST}
do
if [[ "${SERVER_NAME}" = "${HOSTNAME}" ]]
then
export PREFIX=""
echo " - Generating report for : ${SERVER_NAME}"
generate_report > ${REPORT_DIR}/${SERVER_NAME}.html
else
export PREFIX="ssh -l ${USER} ${SERVER_NAME}"
echo "\n - Testing connectivity to server: ${SERVER_NAME}"
if ping -c 1 -w 1 ${SERVER_NAME} >/dev/null 2>&1
then
echo " - ping test ok for server : ${SERVER_NAME}"
${PREFIX} 'echo' >/dev/null 2>&1
if [ "$?" -eq "0" ]
then
echo " - rsh test ok for sever : ${SERVER_NAME}"
echo " - Generating report for : ${SERVER_NAME}"
generate_report > ${REPORT_DIR}/${SERVER_NAME}.html
else
echo " - ERROR: Unable to ssh to : ${SERVER_NAME}"
fi
else
echo " - ERROR: Unable to ping : ${SERVER_NAME}"
fi
fi
done
the issue I have is when the script is run on the local host the ${PREFIX} variable is causing me issues:
${PREFIX} 'if [ -f /usr/bin/lparstat ]
then
LANG=C uname -Ls | read junk partition_number partition_name
echo "Partition Number : ${partition_number}"
echo "Partition Name : ${partition_name}"
fi'
its obvious that there is a problem running the commands with the '<script>'
is there anyway around this otherwise I will have to create another script to be run if the server is the local host.
Thanks in advance and I hope this isnt too confusing.
NB the example about is one of many functions run in the script.
Chris.
hello
Solved! Go to Solution.
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-11-2008 07:08 AM
- Tags:
- eval
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-11-2008 08:21 PM
тАО07-11-2008 08:21 PM
Re: running a command without a prefix
>the issue I have is when the script is run on the local host the ${PREFIX} variable is causing me issues:
Why run on the "local" host? You can ssh back to yourself and treat every system equally.
Why run on the "local" host? You can ssh back to yourself and treat every system equally.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-14-2008 01:23 AM
тАО07-14-2008 01:23 AM
Re: running a command without a prefix
eval works for me - thanks James.
also thanks for the advise dennis as I thought it would be more logical to run commands locally on the local server.
Chris.
also thanks for the advise dennis as I thought it would be more logical to run commands locally on the local server.
Chris.
hello
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
News and Events
Support
© Copyright 2024 Hewlett Packard Enterprise Development LP