LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
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, 10:37 PM   #1
ust
Senior Member
 
Registered: Mar 2003
Location: fasdf
Distribution: Debian / Suse /RHEL
Posts: 1,130

Rep: Reputation: 30
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, 11: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


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


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