linux - Run a specific java program as a different user -


we doing testing , need run java program user other root. on centos 6.5 box. java 8. script calls , executes java program. did following on script without luck.

chown user:user script chmod 06755 script 

this still runs process root. following part of script calls java program , generate process. best way run user instead of root.

#showclasses="-verbose:class" showclasses=  exec /opt/jdk32/bin/java $showclasses -xms80m -xmx120m com.integra.linkage.programdirector "$@" 

when try , run script modification following error

su -c "exec /opt/jdk32/bin/java $showclasses -xms80m -xmx120m com.integra.linkage.programdirector "$@"" -s /bin/sh esadmin  programdirector: no operational mode chosen. usage: programdirector [-wsdl programname ...]     -wsdl       - generate wsdl file     programname - name of 1 or more program classes      -mcs        - connect mcs , wait messages. 

as taken how run script user without password

try using:

su -c "your command right here" -s /bin/sh username 

just changing ownership of file not cause run user, saying can run (root can run everything). need execute command user.

in response update, let's @ why isn't picking arguments pass in:

su -c "exec /opt/jdk32/bin/java $showclasses -xms80m -xmx120m com.integra.linkage.programdirector "$@"" -s /bin/sh esadmin 

i'm going strip out stuff draw attention matters here:

su -c "exec ... "$@"" -s /bin/sh esadmin 

you have 4 sets of unescaped double quotes! going cause problems. instead, can avoid escaping inner quotes, simple pass in command single quotes , try again:

su -c 'exec /opt/jdk32/bin/java $showclasses -xms80m -xmx120m com.integra.linkage.programdirector "$@"' -s /bin/sh esadmin 

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -