LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
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, 11:35 AM   #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, 12: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, 01: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, 01: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, 01: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



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 01:21 PM
Shell Script with ssh & scp ErikJohnson Linux - Software 3 03-11-2004 04:53 PM
Shell Script with ssh & scp ErikJohnson Linux - Networking 1 03-11-2004 04:14 PM
Ssh or logging from shell script Alek Linux - General 5 09-24-2003 10:30 AM
c/c++ running a shell script? thermalpants Programming 3 05-12-2002 11:41 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 04:10 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
Open Source Consulting | Domain Registration