I'm trying to write a shell script that proceses user information on a remote server via SSH. The user to be processed will be read interactively by the script.
My current attempt looks like this
#!/bin/bash echo "Enter username which u want to add" read Student3 ssh root@serverIP "useradd $Student3;" awk -F: '{print $1, $3, $6, $7}' /etc/passwd | grep "^${Student3}"
and it creates empty output.
Without the
grep
call, the output isroot 0 /root /bin/bash bin 1 /bin /sbin/nologin daemon 2 /sbin /sbin/nologin adm 3 /var/adm /sbin/nologin lp 4 /var/spool/lpd /sbin/nologin sync 5 /sbin /bin/sync shutdown 6 /sbin /sbin/shutdown halt 7 /sbin /sbin/halt mail 8 /var/spool/mail /sbin/nologin operator 11 /root /sbin/nologin
With the
grep
call appended as| grep "^${Student3}"
, I get empty output.
ssh root@serverIP
before your awk command - you will have to work out how to escape"
.