• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • paul wheaton
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • Mikalai Zaikin
  • Himai Minh

batch file run from Windows or Linux

 
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 2658
19
Netbeans IDE C++ Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

 
It's weird that we cook bacon and bake cookies. Eat this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic