0

I'm trying to move a file from Java Application Server to DB Server. For that I'm using a shell script. To run the shell script, I'm using Process in Java File. While trying as a stand alone java(class file) in application server using putty, it's moving to DB server. But while trying from application, its not working and process.waitFor() is returning 1.. Need Help.???

Code:

Process p = Runtime.getRuntime().exec("sh "+asyncFilePath+"/ManualAdjFileTransfer.sh "+asyncFilePath+ " "+destPath+" "+ destUserId + " " + destIp + " " + asyncFilePath + " ManAdj_File_Transfer.Log");
p.waitFor()
Xstian
  • 8,184
  • 10
  • 42
  • 72
Sethu R
  • 3
  • 5
  • What do you mean by standalone & application? what is the difference between the two? How do you start application that invokes this class? What I understand is you have two boxes and you need to move a file from one to another , logic is written in shell script and that is getting invoked by a Java class? I think , from our perspective it doesn't matter if one is a DB server and another application server or does it? – Sabir Khan Dec 16 '15 at 10:20
  • Standalone means I'm just running the java file alone from command prompt. but application has been deployed in jboss server. that is what i meant. http://stackoverflow.com/users/3850730/sabir-khan – Sethu R Dec 16 '15 at 10:25
  • so hows that application calling that standalone Java class? I mean, is that class getting invoked in some different way than the way you do via command prompt? – Sabir Khan Dec 16 '15 at 10:29
  • No Sabir. I'm not calling standalone from application. I just tried to run the class from application server box through putty. It's working. But when i tried it from a web page by clicking a link, it's not working. – Sethu R Dec 16 '15 at 10:32
  • Are systems users different in both scenarios? I mean, did you executed stand alone with different user and application running under different user ( not compatible with script permission ? ) . All in all, there are no fixed rules as such, you need to debug with logs etc. – Sabir Khan Dec 16 '15 at 10:51
  • Tq Sabir.. http://stackoverflow.com/users/3850730/sabir-khan – Sethu R Dec 16 '15 at 12:45

1 Answers1

0

It could be a problem of permission:

Process p = Runtime.getRuntime().exec("chmod u+x "+yourscript.sh);

Related Question: Write an executable .sh file with Java for OSX

Community
  • 1
  • 1
  • Almost right. But its not shell script permission. It's a handshake problem b/w app server and db server... Anyway Tq.. http://stackoverflow.com/users/2493678/arianna – Sethu R Dec 16 '15 at 12:44