![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| To execute next UNIX command after ending SFTP process. | gautamc | Shell Programming and Scripting | 3 | 03-20-2008 07:49 PM |
| empty space in java command through unix | shweta_d | Shell Programming and Scripting | 2 | 06-27-2007 05:37 PM |
| Plz Help : How to use write command to execute command on some other terminal | Aashish | UNIX for Dummies Questions & Answers | 2 | 03-03-2006 12:25 PM |
| Executing UNIX command from java on NT | CJ Walt | UNIX for Dummies Questions & Answers | 1 | 06-25-2003 01:39 PM |
| Java program calling a UNIX command | QUartz Ite | UNIX for Dummies Questions & Answers | 2 | 11-15-2001 09:17 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread |
Rating:
|
Display Modes |
|
||||
|
execute command unix with java:possible or not?
hi everybody,
i have a small unix script and i want to use it with java, so how can i executte unix command with java (if it is possible): in fact i want to use some values returned by this script with java swings. is it possible (of course everything is possible) but how can i do? thank you in advance for your help. |
|
||||
|
|
|
|||||
|
It's fairly easy to execute a command that's in your PATH, for example, ls
Code:
import java.io.InputStream;
import java.io.IOException;
public class foo
{
public foo()
{
Runtime rt = Runtime.getRuntime();
Process p = null;
try
{
p = rt.exec( "ls -l" );
}
catch ( IOException ioe )
{
System.out.println( "Error executing file" );
}
InputStream output = p.getInputStream();
System.out.println( output );
}
public static void main( String args[] )
{
foo f = new foo();
System.exit( 0 );
}
}
http://www.devx.com/tips/Tip/14667 that should help. Peace, ZB http://www.zazzybob.com EDIT: My code worked for commands, not scripts. Hay ho. Last edited by zazzybob; 05-14-2004 at 06:09 AM.. |
| Sponsored Links | ||
|
|