• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Chmod from Runtime.Exec

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello All I have a interesting situation where I'm trying to run a shell script test.sh from my web application (I have already informed my client of the security risk assocaited with this).

I'm trying to do a simple chmod 777 before I try to execute the shell script to insure that it has the execute bit is set.

So I do something similar to the below.

Process proc0 = Runtime.getRuntime().exec("chmod 777 test.sh");
//i check the file permissions using the os and it is changed
Process proc1 = Runtime.getRuntime().exec("test.sh");
//doesn't work

BUT if I run the same statements again from a 2nd web page IT works.

It's like in the same request that chmod mod didn't take effect, even though at the OS level it did?

Anyone have any ideas?

Thanks,
Coop

[ May 13, 2004: Message edited by: B Cooper ]
 
B Cooper
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Found out that the call is asynchronous and I needed a waitFor call against the process object to ensure it completed the chmod 777 first before the script call.

thanks,
Coop
 
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nice to know, and thanks for responding with the solution.
 
reply
    Bookmark Topic Watch Topic
  • New Topic