LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
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 01-09-2009, 01:24 AM   #1
tucs_123
LQ Newbie
 
Registered: Dec 2008
Posts: 23

Rep: Reputation: 15
Need help to execute command on Remote machine


Hi,


I need to find the storage capacity of warehouse present on the remote server.

My requirements are:

1)Connect to the remote server
2)Change the directory to particular directory and
3)Know the capacity of warehouse.


Say my commands are:

1)cd /server/warehouse

2)df -k warehouse44


How do I execute above commands on remote server.

When I use

ssh tucs_123@xyz.com 'cd /server/warehouse|df -k warehouse44'


I get message:

df: (warehouse44) not a block device, directory or mounted resource
 
Old 01-09-2009, 01:30 AM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
Since they are two different commands, you can use a semicolon to run them in sequence. Piping the output from one command to the other triggers this error. Moreover, you don't really need to change directory. Just do
Code:
ssh tucs_123@xyz.com "df -k /server/warehouse/warehouse44"
 
Old 01-09-2009, 01:40 AM   #3
tucs_123
LQ Newbie
 
Registered: Dec 2008
Posts: 23

Original Poster
Rep: Reputation: 15
Hey Thanks buddy...It worked......One more thing..If ssh command is executed..It asks for the password.How do I set the password for the server so that I will be able to login to server automatically?
 
Old 01-09-2009, 01:47 AM   #4
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
A bad idea is to use "expect". A better idea is to use configure the server to use public key authentication. The values to change are given in the paragraph of comments above the "UsePAM" line. Then append the public ssh key (rsa or dsa) to the authorized_keys file on the server.
 
Old 01-09-2009, 02:03 AM   #5
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
Yes, set Public Key Authentication. There are plenty of tutorials about this task. Look for them, but first read man ssh. The AUTHENTICATION section gives a good description of the issue.
 
  


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
use putty & JavaScript to execute command on remote machine belaviyo Programming 1 10-13-2008 03:45 PM
How to Enable Alias Command on Remote Machine Using SSH bichonfrise74 Linux - Newbie 7 07-07-2008 06:14 AM
bash - execute commands on a remote machine capture results, etc dkrysak Programming 1 11-18-2005 01:50 PM
remote command execute telnet with 1 command MPowers Linux - Networking 2 06-30-2005 06:31 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08: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