0

I'm writing a bash script to be executed on both Windows and Linux machines from the terminal. One of the lines calls Rscript, a program for executing .R programs. The issue is that in Linux, the command is simply Rscipt, whereas in Windows, it is Rscript.exe. Is there any way to modify the program such that it'll run seamlessly on both Windows and Linux operating systems?

Thank you.

Eliezer
  • 747
  • 7
  • 7
  • Look at [this post](http://stackoverflow.com/questions/6413377/is-there-a-way-to-run-bash-scripts-on-windows). They suggest Cygwin for Windows. – Batman Jun 09 '15 at 20:34
  • 2
    In Windows, the `.exe` is implicit; you can run a command without needing its extension. However, since bash doesn't ship with Windows, you can't really write a bash script that runs on unmodified Windows *at all*. – Charles Duffy Jun 09 '15 at 20:36
  • 3
    ...anyhow, the standard thing is just to ship multiple scripts: `yourscript` for UNIX systems, and `yourscript.bat` (or a modernized alternative, such as using one of the available WSH languages) for Windows; the version that has the executable extension on Windows will always be used in preference on that platform. (On UNIX, using filename extensions is bad form: The shebang at the top of the file will tell both the OS and well-behaved text editors its type). – Charles Duffy Jun 09 '15 at 20:38
  • Beautiful, that's really helpful Charles, thank you for that information. – Eliezer Jun 09 '15 at 20:47

1 Answers1

-1

You can name any Unix executable with suffix .exe, no problem too... the first bits in Linux are magic bits which indicates the real type of one file.

or

Simply use perl or python scripts, Perl and python can work both on Windows and Linux.

MUY Belgium
  • 2,330
  • 4
  • 30
  • 46