discussing some technical aspects covering tools, frameworks, technologies etc (the areas where i m involved and getting experienced) - feel free to discuss!

Friday, September 18, 2009

Multiple commands execution via runtime.exec() in Java

The situation insists you to issue more than one command (native or external) through Java Runtime Environment via (Runtime.getRuntime().exec("Cmd")).

Ideally speaking, there has to be a way to separate/distinguish the commands from one another.

Few search results in Google suggested to use a semicolon in between the commands as 'cmd1;cmd2' in exec() method.

I tried the same way but it did NOT work out. During my trial-and-effort, the white space character did the trick :)

Runtime.getRuntime.exec("pwd date");

But it did work in Unix flavours but NOT in windows :( and i am still finding out a way to resolve.

Hope to get it resolved soon..


About Me

ஏதோ பிறந்தோம், ஏதோ வாழ்ந்தோம் என்றிருப்பதல்ல வாழ்க்கை! எப்படி வாழ்ந்தோம் என்பதும் ஒரு அங்கம். வாழக் கிடைத்த வாழ்க்கையில், ஒரு சிலருக்காவது வசந்தத்தின் முகவரியை அறிமுகம் செய்தோமேயானால் அதுவே வசீகரத்தின் வனப்பைக் கூட்டும்!