LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-25-2008, 11:13 AM   #1
ArthurHuang
Member
 
Registered: Jan 2006
Posts: 174

Rep: Reputation: 30
script programming problem


Hello my friends:

I want to rsh or ssh to a server, then do some actions on the server like:

=========================
#!bin/bash/
rsh -l username servername
cp /home/username/
mkdir src/
=========================

Right now I have the following questions:
1) Why I can successfully log on the server without typing the password?
2) Why I can't
cp /home/username
mkdir src/
after I am on the server?

It seems the actions written within my local scripts have no effect on the server. How to solve this problem?
Or is this bash's nature? If so, are there any other script language can make it?

Thanks!
 
Old 01-25-2008, 11:58 AM   #2
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
When you use a script to rsh to a remote host, your local shell process waits until the rsh command completes. What you are seeing at your console is the output from rsh, which is getting its input from the output of the process which is running on the remote host.
If you want to execute a series of commands on the remote host, you have a couple of options:
1. Create a shell script and transfer it to the remote host, and then have rsh invoke that script as its command argument (man rsh).
2. Use something such as expect (man expect) to issue command strings according to some scripted plan.
3. A scriptable terminal emulator such as C-Kermit may be able to perform the rsh and respond to feedback from the remote host.
--- rod.
 
Old 01-25-2008, 02:52 PM   #3
ArthurHuang
Member
 
Registered: Jan 2006
Posts: 174

Original Poster
Rep: Reputation: 30
Help me a lot.

Thanks!
Quote:
Originally Posted by theNbomr View Post
When you use a script to rsh to a remote host, your local shell process waits until the rsh command completes. What you are seeing at your console is the output from rsh, which is getting its input from the output of the process which is running on the remote host.
If you want to execute a series of commands on the remote host, you have a couple of options:
1. Create a shell script and transfer it to the remote host, and then have rsh invoke that script as its command argument (man rsh).
2. Use something such as expect (man expect) to issue command strings according to some scripted plan.
3. A scriptable terminal emulator such as C-Kermit may be able to perform the rsh and respond to feedback from the remote host.
--- rod.
 
Old 01-27-2008, 05:18 AM   #4
/bin/bash
Senior Member
 
Registered: Jul 2003
Location: Indiana
Distribution: Mandrake Slackware-current QNX4.25
Posts: 1,802

Rep: Reputation: 47
As far as loggin to a server without a password that would require you put your public key on the server:
Here are the instructions.
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
Bash script programming problem ArthurHuang Programming 5 01-23-2008 03:24 PM
shell script programming problem newbie_ken Programming 5 08-16-2004 11:19 AM
send automatic input to a script called by another script in bash programming jorgecab Programming 2 04-01-2004 12:20 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:19 AM.

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