Script to pull uid greater than 1000 from remote server


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Script to pull uid greater than 1000 from remote server
# 1  
Old 07-12-2013
Script to pull uid greater than 1000 from remote server

Hello,

I am trying to get UID # greater than 1000 from all linux server, I tried this script getting this error message, someone please suggest.

Code:
$for i in `cat hostlist.0709.org` ; do ssh -t $i 'awk -F':' "{ if($3 >= 1000) print $0 }" /etc/passwd ' >> output ; done
$ cat output
hostname1
awk: { if( >= 1000) print bash }
awk:       ^ syntax error
$

Thanks,
# 2  
Old 07-12-2013
Try:
Code:
if(\$3 >= 1000)

# 3  
Old 07-13-2013
Create a file myscript.sh
Code:
awk -F':' '{ if($3 >= 1000) print $0 }' /etc/passwd

Then the loop script passes this (unchanged!) to the remote shell
Code:
while read i
do
 ssh -qx "$i" '/bin/sh' <myscript.sh
done <hostlist.0709.org >output

# 4  
Old 07-15-2013
You can also enclose awk command in backquote as below.

Code:
 
for i in `cat hostlist.0709.org` ; do ssh -t $i `awk -F':' "{ if($3 >= 1000) print $0 }" /etc/passwd ` >> output ; done

# 5  
Old 07-15-2013
Quote:
Originally Posted by millan
You can also enclose awk command in backquote as below.

Code:
 
for i in `cat hostlist.0709.org` ; do ssh -t $i `awk -F':' "{ if($3 >= 1000) print $0 }" /etc/passwd ` >> output ; done

That's nonsense|wrong: it would run the `awk command` locally then try to remotely run its output (as a command).
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script connect to remote server, not find files and exit only from remote server, but not from scrip

I have a script, which connecting to remote server and first checks, if the files are there by timestamp. If not I want the script exit without error. Below is a code TARFILE=${NAME}.tar TARGZFILE=${NAME}.tar.gz ssh ${DESTSERVNAME} 'cd /export/home/iciprod/download/let/monthly;... (3 Replies)
Discussion started by: digioleg54
3 Replies

2. Shell Programming and Scripting

Bash Script to pull ipa server name on 500 servers

Hello All, I need help writing a bash script that will run on 500 LINUX servers and do the following: 1. Capture the ipa_server name from /etc/sssd/sssd.conf on a list of 500 servers in the ipahosts file. 2. Write to a file outputing only server name and IPA server name. Root ssh keys... (3 Replies)
Discussion started by: vtowntechy
3 Replies

3. Shell Programming and Scripting

How to Append the output of a script running in remote server to a file in local server?

Hi guys, So i am in server1 and i have to login to server 2, 3,4 and run some script there(logging script) and output its result. What i am doing is running the script in server2 and outputting it to a file in server 2 and then Scp'ing the file to server1. Similarly i am doing this for other... (5 Replies)
Discussion started by: srkmish
5 Replies

4. Solaris

Script to get files from remote server to local server through sftp without prompting for password

Hi, I am trying to automate the process of fetching files from remote server to local server through sftp. I have the username and password for the remote solaris server. But I need to give password manually everytime i run the script. Can anyone help me in automating the script such that it... (3 Replies)
Discussion started by: ssk250
3 Replies

5. Shell Programming and Scripting

find digit which is greater than 1000 in text -using shellscript

Hi All, I am having an abc.txt , which contains some digits Eg:abc.txt 145 566 355 I want write shellscript in suchway that if any digit is greter than 1000 then it shuld display " text files contain digit, which is greater than 1000" Please help me to do so Thanks.. (8 Replies)
Discussion started by: pspriyanka
8 Replies

6. Shell Programming and Scripting

Archive log Pull script from one server to another server

Hi all, Iam looking out for a shell script which pulls archive from Server A to Server B. And at the same time, we dont want the archives which are already pulled in Server B to be removed from Server A. Please help me on this, I have been trying on this for a quiet few time. ... (3 Replies)
Discussion started by: vivi.raghav
3 Replies

7. Shell Programming and Scripting

Script to pull Archives from Server A to Server B

Hi all, Iam looking out for a script which pulls archive logs from Server A to Server B. At the same time we donot want the archives to be deleted from Server A. Request you to please help me on this. Thanks, Vivek (1 Reply)
Discussion started by: vivi.raghav
1 Replies

8. Shell Programming and Scripting

Can a script runned in local server access remote server?

Hi, Im creating a script that is supposed to run commands on remote server using sftp. My script is as below: #!/bin/ksh sftp remote_server mypassword cd /u08/mydir/allfiles mget * .. But this is what I got when I runned the script: Connecting to remote server...... (3 Replies)
Discussion started by: luna_soleil
3 Replies

9. UNIX for Dummies Questions & Answers

Pull a file from a remote server through a shell script

Hi, I am writing a shell script to pull a file from a remote server (Let say its a windows based remote server). One of my criteria is to pull a file only if it is not empty. We have done a similar script to push a file from our end to a remote server and before pushing it we check for the... (2 Replies)
Discussion started by: sashankkrk
2 Replies

10. HP-UX

Remote Printing to HP 1000

Our system is an HP RP5470 11.11. We have had remote printing working for over 6 years. We use NetManage ViewNow software on our Windows client as the LPD. We had no problems with remote printing for any HP printer except for the HP LAserJet 1000. Nothing prints. I sent all the files in the... (2 Replies)
Discussion started by: Stabia
2 Replies
Login or Register to Ask a Question