here is my script. I want to login with another user and do ls -lih
:
#!/bin/bash
su - testuser <<- _EOF_
123456 #password
_EOF_
ls -lih
here is the output when i ran script:
./script.sh
-bash: line 1: 123456: command not found
total 127M
262210 drwxr-xr-x. 9 mazimi mazimi 156K Feb 14 19:05 Desktop
262211 drwxr-xr-x. 2 mazimi mazimi 36K Feb 14 18:26 Downloads
278106 -rw-r--r-- 1 mazimi mazimi 64K Feb 14 22:30 ems.cfg
... # list of files
It does ls -lih
in my home directory not testuser
? How should I fix it?
su
actually works? – Michael Mrozek Feb 14 '12 at 19:25