|
| |||||||||
| Tags: administrator, linux, operating system, shell script, terminal, user account |
![]() |
| | Thread Tools | Search this Thread |
|
#1
| ||||
| ||||
| Selecting a user in a shell script
Hello I run a shell script from a java application, but I need to run the command in the script under a specific user (eg testusr), how to do this in the script knowing that the command su can not save the password of the user in the same line, but it requires a password after typing su. So I can use in this case. What I have to do to achieve this? Any help will be highly appreciated. Thank you in advance. Last edited by Quattro : 25-12-2009 at 02:02 PM. |
|
#2
| ||||
| ||||
| Re: Selecting a user in a shell script
Hi You can transfer the request password for user "testusr" to execute commands with "sudo" and adding in / etc / sudoers this line. Just type the following command in the terminal as a root user. Code: toto ALL = (ALL) NOPASSWD: / path / to / myscript |
|
#3
| ||||
| ||||
| Re: Selecting a user in a shell script
Hi Quote:
|
|
#4
| ||||
| ||||
| Re: Selecting a user in a shell script
Hello I am starting with the credentials of the root or root users (in a group, or other file sudoers). you can do Code: sudo su - oracle Code: testusr @ root ssh sudo / usr / sbin / someusr (currently forget the sudoers for this user) |
|
#5
| |||
| |||
| Re: Selecting a user in a shell script
Hello Quote:
Quote:
Besides the way, if you are root, you can do simply su - oracle without using sudo. |
|
#6
| ||||
| ||||
| Re: Selecting a user in a shell script
Hi Without root access, the only solution is through the cooperation of other users. Either the script is installed in each of them with chown or it is installed under the account running the Java code but in a folder accessible by others and is executable by all users. Each user will then have a folder. ssh in which he put into the file authorized_keys public key of the account running the script using Java, including Quote:
Code: / usr / bin / ssh-i / home / USER_RUNNING_JAVA / .ssh / id_ind USER_RUNNING_THE_SCRIPT@your.server.com "path_to_script / thescript.sh" |
![]() |
|
| Thread Tools | Search this Thread |
| |
Similar Threads for: "Selecting a user in a shell script" | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How can I create shell script which find out who the active, current user is? | mANICKAVASAN | Windows Software | 4 | 20-10-2010 12:56 PM |
| shell script SSH not working | Lilya | Software Development | 9 | 16-10-2010 02:53 AM |
| Shell script with sed | Ameeryan | Software Development | 5 | 23-12-2009 02:29 PM |
| Shell Script Formatting | abhi701 | Software Development | 1 | 04-07-2009 05:30 PM |
| Unix Shell Script | BlackSunReyes | Software Development | 3 | 12-08-2008 02:57 PM |