- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Executing a Remote Shell Script
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
Forums
Discussions
Discussions
Discussions
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
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
01-12-2007 03:15 AM
01-12-2007 03:15 AM
remsh server -l user -n "cd /full/path/of/script/;ls;'callscript $host $dbase $rdg'"
When the "ls" is called I can see the "callscript", but when the script is actually called I get:
sh: callscript host dbase rdg: not found.
Where host, dbase, rdg are values entered by the user. Now, I can take that exact line "callscript host dbase rdg" and it will run succesfully while I'm logged into the remote workstation. The workstations .rhosts file is updated with:
myserver myusername
+ myusername
Any advice on what I need to add to my local script to run the remote script successfully?
Thanks.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2007 03:21 AM
01-12-2007 03:21 AM
Solution/full/path/of/script/callscript
. and /full/path/of/script/ are in in the default PATH - and . should NEVER be.
Rdgs...Geoff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2007 03:28 AM
01-12-2007 03:28 AM
Re: Executing a Remote Shell Script
change your command line to use the pathname and drop the wrong usage of the single quotes:
remsh server -l user -n "cd /full/path/of/script/;ls;./callscript $host $dbase $rdg"
Your attempt tries to locate a program
'callscript host dbase rdg' (spaces are part of the program name!) via the PATH variable.
mfG Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2007 03:29 AM
01-12-2007 03:29 AM
Re: Executing a Remote Shell Script
sh: /home/gp7200/550-PROD/scripts/callPRODscripts 10.31.152.94 3424 7374: not found.
Modified the script to have:
remsh server -l user -n "'/full/name/of/path/callscript $host $dbase $rdg'"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2007 03:34 AM
01-12-2007 03:34 AM
Re: Executing a Remote Shell Script
I modified the line to:
remsh server -l user -n "/full/name/of/path/callscript $host $dbase $rdg"
And now receive:
/full/name/of/path/callscript: expect: not found.
In the remote script "callscript", I'm using the "expect" function- is there something in my local script I need to add to specify a location of "expect"?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2007 04:01 AM
01-12-2007 04:01 AM
Re: Executing a Remote Shell Script
it is good practise to check for the existence of non-standard tools, which you are using in scripts.
If its a ksh script, you can do it like this:
#
if ! whence expect >/dev/null
then PATH=$PATH:/path/where/tools_are_found
fi
If you have a setup of an environment commonly used after a normal login (e.g. /usr/local/env/common.env), you could source it explicitly in your remsh-command:
remsh server -l user -n ". /usr/local/env/common.env; cd /full/path/of/script/;ls;./callscript $host $dbase $rdg"
mfG Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2007 04:13 AM
01-12-2007 04:13 AM
Re: Executing a Remote Shell Script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2007 04:25 AM
01-12-2007 04:25 AM
Re: Executing a Remote Shell Script
you can check:
echo $PATH
remsh -l user -n 'echo $PATH'
Reasons:
- it's another user, you are connected to
- it's a remote server and your toolpath may vary
- it's not an interactive session you are using, so some setting may not be done
mfG Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2007 06:19 AM
01-12-2007 06:19 AM
Re: Executing a Remote Shell Script
I did a "which expect" on both servers, and the expect function appears to be located in the same directory on both (/apps/bin/expect).
I guess I'm still confused as to why I'm getting that "not found" message if "expect" is located in the same place on both servers.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2007 06:39 AM
01-12-2007 06:39 AM
Re: Executing a Remote Shell Script
usually, I just set the path to what I need it to be in the script and be done with it.............
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2007 07:04 AM
01-12-2007 07:04 AM
Re: Executing a Remote Shell Script
/usr/local/bin/expect
not
expect
Rgds...Geoff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2007 07:18 AM
01-12-2007 07:18 AM
Re: Executing a Remote Shell Script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2007 08:40 AM
01-12-2007 08:40 AM
Re: Executing a Remote Shell Script
PS - welcome to the forums!
Please have a read through:
http://forums1.itrc.hp.com/service/forums/helptips.do?#28
Basically, points help people determine the relevance of the answer when they search the ITRC for similar questions.
Also, it is a good idea to close a thread when you are satisfied with the answers.
Thanks...Geoff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2007 09:35 AM
01-12-2007 09:35 AM
Re: Executing a Remote Shell Script
#!/usr/bin/sh
set -u
export PATH=/usr/bin:/usr/contrib/bin....
The first defines the correct shell to use for interpreting the script. The second line prevents spelling errors for variables by stopping the script. The third defines the PATH required for this script. You add only the paths needed for your script. This PATH only exists inside your script. You can hardcode full pathnames in your scripts but it is a lot of extra work -- that's why defining PATH locally makes more sense. Additionally, PATH is a potential security risk so your scripts should never use the currently defined PATH value.
You also look at your required environment variables. To see what is currently defined, use the env command, then pick the ones needed by your script.
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2007 05:57 AM
01-16-2007 05:57 AM