aspose file tools*
The moose likes I/O and Streams and the fly likes .sh file not found Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark ".sh file not found" Watch ".sh file not found" New topic

.sh file not found

Srinivas Ivaturi
Ranch Hand

Joined: Jan 28, 2003
Posts: 50

I am trying to execute a .sh file using Runtime.getRunTime() as below. It says that file is not found. But the file exisits in the path. Here is the code snippet I am using. The environment is any non windows environment I am getting this execption.

Process process = Runtime.getRuntime().exec("/data1/eqa/Installdir/ssacrm1408/shared/bin/" com.test.profileloader );

Exception is :

err, "/data1/eqa/Installdir/ssacrm1408/shared/bin/": not found
at java.lang.UNIXProcess.forkAndExec(Native Method)
at java.lang.UNIXProcess.<init>(
at java.lang.Runtime.execInternal(Native Method)
at java.lang.Runtime.exec(
at java.lang.Runtime.exec(
at java.lang.Runtime.exec(
at java.lang.Runtime.exec(
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 39578
FileNotFoundException is also thrown in other circumstances, e.g. if the process does not have permission to read the file.

Are you sure that the command you're exectuing is syntactically correct? This looks strange (not like proper Java code):

("/data1/eqa/Installdir/ssacrm1408/shared/bin/" com.test.profileloader );"

Ping & DNS - updated with new look and Ping home screen widget
Srinivas Ivaturi
Ranch Hand

Joined: Jan 28, 2003
Posts: 50
All permissions are there for that file. I mistyped the command.
Process process = Runtime.getRuntime().exec("/data1/eqa/Installdir/ssacrm1408/shared/bin/ com.test.profileloader" );

Is there any other problem that you see?

Srinivas Ivaturi
Vlado Zajac
Ranch Hand

Joined: Aug 03, 2004
Posts: 245
Does the command
/data1/eqa/Installdir/ssacrm1408/shared/bin/ com.test.profileloader
work from shell?
Srinivas Ivaturi
Ranch Hand

Joined: Jan 28, 2003
Posts: 50
yes, it works for me.
jQuery in Action, 2nd edition
subject: .sh file not found
Similar Threads
Process Not enough space
del command with Runtime.exec()
Exception - Running command line from Java
Regarding accessing environment variables