Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

change user 1

Status
Not open for further replies.

cantubas

Programmer
Jan 8, 2004
45
FR
can I change the user in a script??

 
yes I can use the function man but I don't find a command where I give in password the login and the password.
 
I think within the script you can say

su - username<<EOF
 
How would this let you specify the password?
Would the password go on the next line?

DJL

A salesman is a machine for turning coke into obnoxious arrogance.

Common sense is what tells you the world is flat.

 
I just tried

su - username<<EOF
password

and I still got prompted for a password after this.
Would you be able to post an example?
Cheers,
Douglas JL.

A salesman is a machine for turning coke into obnoxious arrogance.

Common sense is what tells you the world is flat.

 
#ch_user.sh
#Have included the line whoami just to show the username after I run the script

su - batch_daily <<EOF
AlphA01
whoami



 
No, it still prompts me for the password.
I guess maybe the password is something they didn't want hardcoding?
DJL

A salesman is a machine for turning coke into obnoxious arrogance.

Common sense is what tells you the world is flat.

 
su - batch_daily <<EOF
AlphA01
whoami
EOF

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
when I try
su -eleve2 << EOF
eleve2
whoami
EOF

I have:

su: illegal option -- e
su: illegal option -- l
su: illegal option -- e
su: illegal option -- v
su: illegal option -- e
su: illegal option -- 2
Password:

 
You maybe need a space after the dash in the su line?

A salesman is a machine for turning coke into obnoxious arrogance.

Common sense is what tells you the world is flat.

 
su - eleve2 << EOF
eleve2
whoami
EOF

I have:

Password:


NB: i works on HP UX
 
The way I got around this was as follows.
Create a script for the vision user called vscr.sh.
Then, as root, run a script with with the following line in it:
su - vision -c vscr.sh

This ran the script OK in a shell as the vision user.

A salesman is a machine for turning coke into obnoxious arrogance.

Common sense is what tells you the world is flat.

 
The more acceptable way of running stuff as other users (interactive or scripted) is &quot;sudo&quot;.

Yes, there is coding in place that prevents &quot;su&quot; (or most other commands) from accepting a password from a non-interactive source.
 
Hi.
Maybe sudo isn't a universal unix command?
I can't find any reference to it in the manual & it doesn't seem to be recognised when I try to call it.
DJL

A salesman is a machine for turning coke into obnoxious arrogance.

Common sense is what tells you the world is flat.

 
Yes only root can &quot;su&quot; without providing a password.
Obviously you shouldn't be able to provide a password from a readable file ... because it would be an humoungus leak in the security system ... because everybody could read that file.
sudo is not a standard command, but an third party utility
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top