LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-27-2005, 11:37 PM   #1
thorney
Member
 
Registered: Jul 2005
Location: Canada
Distribution: Ubuntu Hardy
Posts: 98

Rep: Reputation: 15
Need help with shell scripts


Hi,

How do I write a shell script that logs me into a remote machine, executes commands on the remote machine and then exits and returns me to my local machine prompt? (I have setup ssh to allow key authentication.) Any help would be awesome!!

thanks
 
Old 11-27-2005, 11:59 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,066
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
Something like this?

Code:
#!/bin/bash
scp file user@remote-machine:/path/to/file
ssh user@remote-machine "commands; ..."

Cheers,
Tink
 
Old 11-28-2005, 12:09 AM   #3
thorney
Member
 
Registered: Jul 2005
Location: Canada
Distribution: Ubuntu Hardy
Posts: 98

Original Poster
Rep: Reputation: 15
Ya I guess. So I take it that any commands that are in quotes get executed on the remote machine!?
 
Old 11-28-2005, 12:17 AM   #4
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,066
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
That's right. If it's only a single command you can skip the
quotes, too.


Cheers,
Tink
 
Old 11-28-2005, 12:18 AM   #5
thorney
Member
 
Registered: Jul 2005
Location: Canada
Distribution: Ubuntu Hardy
Posts: 98

Original Poster
Rep: Reputation: 15
Thanks Tinkster
 
  


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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
shell scripts rocketgo Linux - General 10 12-01-2003 06:20 AM
Shell Scripts benwy Linux - Software 1 06-09-2003 03:58 AM
Shell scripts j0hn0n1 Linux - Software 1 01-03-2003 04:11 PM
shell scripts nautilus_1987 Linux - General 3 08-30-2002 04:12 AM
shell scripts gui10 Programming 10 10-28-2001 03:46 AM


All times are GMT -5. The time now is 12:57 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration