LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices



Reply
 
Search this Thread
Old 10-08-2005, 12:35 PM   #1
davee
Member
 
Registered: Oct 2002
Location: Ayrshire, Scotland
Distribution: Suse(home) RHEL (Work)
Posts: 263

Rep: Reputation: 30
Running a shell script remotely via 'ssh <hostname> <command>'


If I use the above format to run a shell script, it runs the script locally.

How can I get it to run on the remote box? It requires binaries (i.e. sqlplus, sqlloader) that are not on my local box. I only want the ssh command to kick it off remotely...

Dave
 
Old 10-08-2005, 01:30 PM   #2
nixcraft
Member
 
Registered: Nov 2004
Location: BIOS
Distribution: RHEL3.0, FreeBSD 5.x, Debian 3.x, Soaris x86 v10
Posts: 379

Rep: Reputation: 30
You need sqlplus, sqlloader etc on remote box, then you can use it. SSH cannot do such work
 
Old 10-08-2005, 02:03 PM   #3
davee
Member
 
Registered: Oct 2002
Location: Ayrshire, Scotland
Distribution: Suse(home) RHEL (Work)
Posts: 263

Original Poster
Rep: Reputation: 30
That's what I mean - the script, sqlloader, sqlplus, etc, etc are all on the remote box. I only want to start the thing running via ssh from my local box.

Dave
 
Old 10-08-2005, 02:59 PM   #4
Quigi
Member
 
Registered: Mar 2003
Location: Cambridge, MA, USA
Distribution: Ubuntu (Dapper and Heron)
Posts: 377

Rep: Reputation: 31
Then you're on the right track. My experience with ssh says it would run remotely. So make sure to
  • omit the single quotes around the command line (but it wouldn't run locally with them anyway),
  • replace <hostname> with the name of the host,
  • replace <command> with the path to the script.
Well probably you did that. What makes you think it ran locally? I mean, what output did you expect? What did you get?

You could try with a simple known command first. E.g., "hostname" or "uname -a" -- without the double quotes. Like this,
Code:
ssh other-host uname -a
From the output it should be obvious where it ran (if the two machine have different names). If that still runs locally, check if your <hostname> gets resolved to the correct IP address. If you just run 'ssh <hostname>' and give no command, does that successfully give a shell on the remote host?
 
Old 10-09-2005, 02:38 AM   #5
davee
Member
 
Registered: Oct 2002
Location: Ayrshire, Scotland
Distribution: Suse(home) RHEL (Work)
Posts: 263

Original Poster
Rep: Reputation: 30
Ah hah! thanks for that -

Turns out that the environment for sql is set from the .profile - this wasn't being processed before the command was run via ssh.

Running:

ssh hostname '. /home/user/.profile; command.sh'

gave the right result.

Thanks for putting me on the right track.

Dave
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
running shell script: command not found tripat Red Hat 3 04-14-2010 02:21 PM
Shell Script with ssh & scp ErikJohnson Linux - Software 3 03-11-2004 05:53 PM
Shell Script with ssh & scp ErikJohnson Linux - Networking 1 03-11-2004 05:14 PM
Ssh or logging from shell script Alek Linux - General 5 09-24-2003 11:30 AM
c/c++ running a shell script? thermalpants Programming 3 05-12-2002 12:41 PM


All times are GMT -5. The time now is 08:43 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration