LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
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 04-14-2007, 06:40 AM   #1
haresh_dba
LQ Newbie
 
Registered: Apr 2007
Posts: 1

Rep: Reputation: 0
Cannot run shell script on the remote server


Hi

I`m unable to execute my shell script on the remote db server for monitoring. However i`m able to connect the remote server but the scripts are not executing remotely.

I would like to run the scripts on the remote box

Please help
 
Old 04-14-2007, 08:40 AM   #2
MensaWater
Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 5,995
Blog Entries: 5

Rep: Reputation: 782Reputation: 782Reputation: 782Reputation: 782Reputation: 782Reputation: 782Reputation: 782
You can't execute a script from a local box on a remote box. You can however put in commands to execute on a remote box from the local box OR you can copy the local script to the remote box then use the local box to tell it to run there.

Say you had a simple script and named it "showme.sh"
Code:
#!/bin/bash
ls -l
df -h
This script should run fine on the local box just by typing "./showme.sh". However if you tried to run it remotely by typing:

ssh user@remotehost ./showme.sh

It wouldn't work because showme.sh doesn't exist on the remote. You could simply copy this to the remote host and then run it.

Alternatively you could modify the script:
Code:
ssh user@remotehost "/bin/ls -l"
ssh user@remotehost "/bin/df -h"
Here you're telling it to execute each of the commands of the script remotely. The downside of this is that if you don't have an ssh trust setup it will prompt you for the password each time it executes and ssh in the script.
 
Old 04-14-2007, 09:26 AM   #3
XavierP
Moderator
 
Registered: Nov 2002
Location: Kent, England
Distribution: Lubuntu
Posts: 19,176
Blog Entries: 4

Rep: Reputation: 430Reputation: 430Reputation: 430Reputation: 430Reputation: 430
Moved: This thread is more suitable in Linux-General and has been moved accordingly to help your thread/question get the exposure it deserves.
 
  


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
Is there a way to easily shutdown a remote linux server with a shell script? bdb4269 Programming 7 01-26-2007 04:08 PM
how to run a shell script in the perl script sharad Linux - General 1 05-24-2006 03:23 AM
Shell script to run pl/sql script. colly Linux - General 1 09-09-2004 06:49 AM
Remote Win Bat File execute Shell Script on AIX Server DriveMeCrazy AIX 5 05-26-2004 06:24 PM
telneting remote machine from a shell script sanjith11 Programming 11 05-26-2004 06:50 AM


All times are GMT -5. The time now is 06:58 PM.

Main Menu
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