Java – Need to execute script file using sudo – run from teamcity

antexecjavasudoteamcity

I need to execute a script in Linux platform "runme.sh" (which can be executed as sudo user) using another ant script "build.xml". Now i have execute this build.xml from teamcity.

I have code for everything but got struck into while invoking "runme.sh" using sudo in build.xml from team city.

In build.xml i have code like

    <exec dir="${installdir}" executable="/bin/sh">
        <arg line="-c 'sudo ./runme.sh'"/>
        <redirector inputstring="sudopassword"/>        
    </exec>

In team city I get error as " [exec] sudo: sorry, you must have a tty to run sudo".

Can someone please help me resolve this error?

thanks in advance

Best Answer

If you type "sorry, you must have a tty to run sudo" in a search engine, you obtain the following instructions on first link (http://www.zimbra.com/forums/installation/10553-solved-sudo-sorry-you-must-have-tty-run-sudo.html):

" vi /etc/sudoers

comment out: #Default requiretty "

BR Eric