SHaFqaT M
SHaFqaT M

Reputation: 1

How can I pass a password from a file to the "su" command?

How can I pass password to su command in shell script from another text file.

password.txt is like

password=tryme

shell script need to be ran by user gucq1

shell script is like

#!/bin/bash

cd /pstools/85419/jre/bin
java -Xms1024M -Xmx1024M -Dhttps.protocols=TLSv1.2 -Djdk.tls.client.protocols=TLSv1.2 -jar /app1/nohr/soft/85419/gucq1/cust/classes/SVC_TestS.jar 

I need to run this script with different id (gucq1) than I am logged in with (autoid).

I dont want to use SUDO as I dont have access to it.

Upvotes: 0

Views: 1496

Answers (2)

Matias Barrios
Matias Barrios

Reputation: 5054

Although I don't recommend it, you can use SUDO like this.

echo "mypassword" | sudo -S ./somescript ;

Regards!

Upvotes: -2

Jessie Koffi
Jessie Koffi

Reputation: 176

https://unix.stackexchange.com/questions/113754/allow-user1-to-su-user2-without-password#115090

if you change your /etc/pam.d/su, you can use

su gucq1 -c <command>

without su prompting for password.

Upvotes: -1

Related Questions