• Post Reply Bookmark Topic Watch Topic
  • New Topic

to execute commands in linux through java  RSS feed

 
Amit Bathla
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi
actually we have a project where we use Runtime class and its exec() method
to run dos commands on windows platform.but our requirements are now different .we now want either a dos command where we can open a file which contains a particular phrase or a keyword.

can we find such a dos COMMAND ?

OR

we can choose for linux platform.but the trouble is i dont know how to run commands in linux platform by using exec() method of Runtime class.

please help me soon.
 
Alton Hernandez
Ranch Hand
Posts: 443
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by amit bathla:
hi
actually we have a project where we use Runtime class and its exec() method
to run dos commands on windows platform.but our requirements are now different .we now want either a dos command where we can open a file which contains a particular phrase or a keyword.

can we find such a dos COMMAND ?

OR

we can choose for linux platform.but the trouble is i dont know how to run commands in linux platform by using exec() method of Runtime class.

please help me soon.



RunLinux.java
 
Stefan Wagner
Ranch Hand
Posts: 1923
Linux Postgres Database Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you looking for something like the 'find' command for DOS?
I'm pretty sure there is one, perhaps called 'find' too or 'search'.

At least there are the UnxUtils here: UnxUtils which include grep.



These are native windows ports of the GNU Utils and don't need a cygwin or some emulator.

On Linux it would be in the example above:
 
Tim Holloway
Saloon Keeper
Posts: 18789
74
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Stefan Wagner:
Are you looking for something like the 'find' command for DOS?
I'm pretty sure there is one, perhaps called 'find' too or 'search'.

At least there are the UnxUtils here: UnxUtils which include grep.



These are native windows ports of the GNU Utils and don't need a cygwin or some emulator.

On Linux it would be in the example above:


There is a Unix find command and it bears about as much resemblance to the DOS find command as MS-Word does to Windows Notepad, funtionally speaking.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!