Local shell script need to be executed on a remote linux box


 
Thread Tools Search this Thread
Operating Systems Linux Local shell script need to be executed on a remote linux box
# 1  
Old 05-01-2008
Local shell script need to be executed on a remote linux box

I need to execute a shell script on a remote linux box. But the shell script resides on the local linux box where I am currently logged in. Is there a way to do this? I know rsh <host> <command> can execute a command on the remote host.
# 2  
Old 05-01-2008
Sort Command!

When I am sorting a file I am getting a warning message
"Warning: A newline character was added to the end of file".

Please let me know hwy I am getting these warnings.

Thanks
Sumit
# 3  
Old 05-01-2008
ssh

hi,

login as root on your local machine and copy the sh file to remote system using scp command and ssh to remote system and execute there.
# 4  
Old 05-01-2008
Quote:
Originally Posted by sumitc
When I am sorting a file I am getting a warning message
"Warning: A newline character was added to the end of file".

Please let me know hwy I am getting these warnings.

Thanks
Sumit
sumitc,

Don't hijack anothers thread but start a new thread.

Thanks.
# 5  
Old 05-01-2008
Quote:
Originally Posted by uneex
hi,

login as root on your local machine and copy the sh file to remote system using scp command and ssh to remote system and execute there.
Is it interactive? does it require entering password?

I need to automate this - i.e., I need to write a script which does this (run the local script on the remote box) on may be 100 boxes one by one.
# 6  
Old 05-02-2008
SSH from local to remote

Rajesh,
Depends on what you really want to do? SSH is interactive, it's just like telnet, but secure.
You can ssh from your local Linux (or UNIX) to remote box and execute the script. Now, if you don't want to copy the script to the remote box, you can share a local directory using NFS (put your script in that dir). Then ssh to remote server, mount the NFS and execute the script. I think that is what you may be looking for. You can even automate all these steps too!

HTH,

Nitin Smilie
# 7  
Old 05-02-2008
I found that it can be done in 3 steps..

#1. remote copy your local script - this wont ask for password. i think you
# need to have same userid/passwd setup on the remote host
rcp yourscript.sh remote_hostname:/remote_path/yourscript.sh

#2. Execute the script on the remote box
rsh remote_host /remote_path/yourscript.sh

#3. Delete it
rsh remote_host rm /remote_path/yourscript.sh

Thanks for your responses...
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Except script to run a local shell script on remote server using root access

local script: cat > first.sh cd /tmp echo $PWD echo `whoami` cd /tmp/123 tar -cvf 789.tar 456 sleep 10 except script: cat > first #!/usr/bin/expect set ip 10.5.15.20 set user "xyz123" set password "123456" set script first.sh spawn sh -c "ssh $user@$ip bash < $script" (1 Reply)
Discussion started by: Aditya Avanth
1 Replies

2. Shell Programming and Scripting

Linux/bash Script only working if executed from shell prompt

Hi, maybe I'm asking a VERY dumb question, but would anybody out there tell me, why this f****** script won't work if executed as a cronjob, but works fine if executed from a shell prompt? #! /bin/bash set PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin date >>... (3 Replies)
Discussion started by: beislhur
3 Replies

3. Shell Programming and Scripting

Check/get the exit status of a remote command executed on remote host through script

Geeks, Could you please help me out in my script and identify the missing piece. I need to check/get the exit status of a remote command executed on remote host through script and send out an email when process/processes is/are not running on any/all server(s). Here's the complete... (5 Replies)
Discussion started by: lovesaikrishna
5 Replies

4. Shell Programming and Scripting

Notify when the script run(hourly)on my jump-box only when there is a failure on my remote-box

Team, Presently I have a script, which i have set up cron on one of my Jump-boxes,and gives me the output on every hourly basis,fetching the data from the remote machine.Basically it gives me the list of all active users logged and its count once we execute the script.Here the count is... (6 Replies)
Discussion started by: whizkidash
6 Replies

5. UNIX for Dummies Questions & Answers

Copy files from Linux server local windows machine using a shell script

Hello, I need to create a shell script which will copy files - which are created on particular date and starting with particular name - to local windows XP machine. Is this possible.? Currently it is being done manually using winscp (1 Reply)
Discussion started by: NarayanaPrakash
1 Replies

6. Shell Programming and Scripting

To run a local shell script in a remote machine by passing arguments to the local shell script

I need to run a local shell script on a remote machine. I am able to achieve that by executing the command > ssh -qtt user@host < test.sh However, when I try to pass arguments to test.sh it fails. Any pointers would be appreciated. (7 Replies)
Discussion started by: Sree10
7 Replies

7. UNIX for Dummies Questions & Answers

SQL block in a Shell Script connecting to a local and remote DB

Hi All, In a Shell scriipt with a SQL block I want to issue a query against a local DB and a remote DB on a remote server. The shell script is running locally. This is how I connect to the local server. But I want the query to reference remote table in the join. Question can I specify a... (1 Reply)
Discussion started by: daveu7
1 Replies

8. Linux

How to find remote Linux box login account without login in to that box?

Hi, How to find remote Linux box login account without login in to that box? I don't have login account at my remote Linux box. But I need who are all having login account. How do I findout? Thanks, --Muthu. (3 Replies)
Discussion started by: Muthuselvan
3 Replies

9. Shell Programming and Scripting

ftp file starting with particular name on Windows box to Unix box using shell script

Hello all ! I'm trying to write a shell script (bash) to ftp a file starting with particular name like "Latest_" that is present on a Windows box to UNIX server. Basically I want to set this script in the cron so that daily the new build that is posted on the Windows box can be downloaded to the... (2 Replies)
Discussion started by: vijayb4u83
2 Replies

10. Shell Programming and Scripting

Script to Reboot a linux box from a windows box

HI All, I need a script to reboot a linux box from a windows box. The script needs to run automatically whenever a sitescope alerts with an error message. Have searched for this in the forums, but could not get something relative. Pls. let me know the various alternatives we have to do... (2 Replies)
Discussion started by: Crazy_murli
2 Replies
Login or Register to Ask a Question