I would like to execute a shell script from an ant build (I saw the exec task seems to do it), but this script has to be executed from a user different thant the one launching ant. Is there a way to do this?
Asked
Active
Viewed 3,413 times
2 Answers
2
Couldn't you execute, from ant, a script that executes the actual script using sudo
? See How to pass the password to su/sudo/ssh without overriding the TTY? for how to pass the password from the command line.
-
I tried this using bash (default terminal) and it works. ANT, however, doesn't seem to be able to execute the trick and seems to not read the password: [exec] [exec] Password: [exec] Sorry, try again. [exec] Password: [exec] Sorry, try again. [exec] Password: [exec] Sorry, try again. – Michahell Oct 27 '12 at 22:23
2
You could use the sshsexec task. Connect locally or to a remote machine:
<sshexec host="localhost"
username="dude"
password="yo"
command="touch somefile"/>
This task will require the optional jsch.jar to be installed in your ANT lib.
Specifying a pirvate key would enable a password-less login.

Mark O'Connor
- 76,015
- 10
- 139
- 185