Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

batch file run from Windows or Linux

 
Rahul Shilpakar
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i got success in running a batch file on windows platform. but want to run batch file equivalent in Linux and write the code in same class from which i executed batch file of windows. means my application may reside on windows or Linux. so i want to make such code that i don't need to worry about the batch extension or other extension for corresponding OS.

for ex.

method(){
{
// code goes here
// now i want such code that my program will detect which OS i have
// and excecute batch file if it is windows OR .sh (i think so) if
// my OS is Linux.
}

how can i do this. please tell me
 
Jan Cumps
Bartender
Posts: 2588
11
C++ Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
System.getProperty("os.name");
System.getProperty("os.version");

Tutorial available at sun:
Essential Classes - The Platform Environment - System Properties

Regards, Jan
 
Rahul Shilpakar
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes i got it. thank you very much. now i just need to detect my OS and then execute the corresponding batch file extension after checking the condition.

OK, fine.





Software metrics let you know when to laugh and when to cry.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic