LinuxQuestions.org
Visit Jeremy's Blog.
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 07-22-2009, 09:37 PM   #1
ust
Senior Member
 
Registered: Mar 2003
Location: fasdf
Distribution: Debian / Suse /RHEL
Posts: 1,130

Rep: Reputation: 31
run script on remote server


I have the below script, it is ok to run on local server

#cat /etc/passwd | awk -F: '{ print $1}'

root
bin
daemon
adm
lp
sync
shutdown
halt


But if I try to run it at remote server , i tried ssh root@192.6.4.108 "cat /etc/passwd | awk -F: '{ print $1}'" , then the output is as below , the output format is different , can advise what is wrong , how can i use the existing script to run on remote server ? thx




root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt
 
Old 07-22-2009, 10:02 PM   #2
born4linux
Senior Member
 
Registered: Sep 2002
Location: Philippines
Distribution: Slackware, RHEL&variants, AIX, SuSE
Posts: 1,127

Rep: Reputation: 49
$1 is treated as a shell variable. you need to "escape" the $:

ssh root@192.168.4.108 "awk -F: '{print \$1}' /etc/passwd"

(oh i omitted your cat - its pretty much useless. )
 
  


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
run a shell script on remote client from a server to find all its running process robin singh Linux - Newbie 7 10-03-2008 11:32 AM
Cannot run shell script on the remote server haresh_dba Linux - General 2 04-14-2007 09:26 AM
Will script continue to run even after closing putty for remote access anjanesh Linux - Newbie 11 08-07-2006 03:05 AM
run programs on a remote computer with script, how? cmisip Linux - Networking 5 07-07-2003 01:48 PM

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

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