On Fri, Feb 3, 2012 at 5:53 AM, abhisheks <[email protected]> wrote: > i am developing a web application using apache wickets. I need to call a > shell script residing on my local disk from java code. > > this is the section of code under concern : > > ProcessBuilder builder = new > ProcessBuilder("sh","/media/drive_/MtechDocuments/ProgramingNOTES/RunShellfromJAVA/test.sh"); > builder.redirectErrorStream(true); > final Process process = builder.start(); > } > process.waitFor(); > > ------ > > This is piece of code successfully runs fine and execute a shell when this > code is a part of java prgram residing anywhere on my laal disk. However, > when i make a jar file of a progeam , put in webapps folder , and start the > web application , it reports permission denied error on test.sh script. > > I then modify the line as : > > ProcessBuilder builder = new ProcessBuilder("sudo", "-A", > "sh","/media/drive_/MtechDocuments/ProgramingNOTES/RunShellfromJAVA/test.sh"); > and set the SUDO_ASKPASS env variable to script returning my sudo password , > then it reports the following error : > sudo: 3 incorrect password attempts and script calling is failed. Again this > works correctly when i run the program outside the web development > environment , it is able to read my sudo password correctly at run time with > -A option. Why is it failing when running the same program from web > application ? please help !!
Maybe your web server runs with a user which has no permissions to become different user (via sudo). When you run it as a normal Java program you run it with your user which has this permission. In any case it has nothing to do with Wicket. > > > -- > View this message in context: > http://apache-wicket.1842946.n4.nabble.com/calling-shell-script-from-Wicket-java-program-tp4353583p4353583.html > Sent from the Users forum mailing list archive at Nabble.com. > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > -- Martin Grigorov jWeekend Training, Consulting, Development http://jWeekend.com --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
