-2

I have one .bat script on my windows share that is mounted to my UNIX machine. Bat script is set to make file transfer between 2 windows shares, but I would like to trigger this script from a unix machine if that is possible. I was reading that you can do it with wine or dosbox, but I don't have that installed on my unix. Is it possible to resolve this problem with some additional .sh script that will trigger my .bat script correctly?

Thank you in advance. Best regards.

Aljaz
  • 303
  • 4
  • 18
  • Your question don't explain your real problem and motivation. Why do you need file transfers across various operating systems? What kind of file or data are you sharing? Please **edit your question** to improve it and motivate it. Smells like some [XY problem](http://xyproblem.info) – Basile Starynkevitch Oct 25 '17 at 08:31
  • What is your `.bat` script doing? Perhaps showing some of it in your question could be helpful. You should **improve your question** – Basile Starynkevitch Oct 25 '17 at 08:51
  • Hi, it is no importatn what my script is doing between 2 windows shares. The question is how to trigger .bat script that is on windows share from unix machine. This windows share is mounted to unix, script is transffering .csv files from one win to another win machine, but the point is that I would like to trigger that script from unix machine. – Aljaz Oct 25 '17 at 11:06
  • Where is the script running? On a Unix system or on a Windows one? From what machine are you (remotely) starting it? How do you do that? Your question shows some confusion. Improve it by naming the local machine, the distant machine, the `.sh` Unix script, the `.bat` Windows script, tell which OS each of these machines is running, and where are the various scripts located. **Your question is unclear** and should be edited and improved! Explain what *relevant* services are running and where. – Basile Starynkevitch Oct 25 '17 at 11:17
  • BTW, your title is confusing. Apparently your are *not* wanting to run a `.bat` script on a Unix machine. So **improve your question** (perhaps you want to remotely execute -from a Unix machine- on a Windows server some `.bat` script); I don't understand your goals. – Basile Starynkevitch Oct 25 '17 at 11:21

1 Answers1

-1

You cannot run a .bat script on a Unix machine for several reasons :

  • Unix has not the same commands (on the command line) as Windows. The POSIX standard defined a set of commands, if you use them you'll be portable on various POSIX systems (but not on Windows); for example to list a directory, you'll use DIR on MSDOS and Windows but ls on Unix and POSIX; to copy a file it is COPY on MSDOS and Windows but cp on Unix and POSIX; etc....

  • Unix has not the same command interpreter as Windows. The POSIX standard and the Unix tradition provides a Unix shell and POSIX has standardized /bin/sh (a.k.a. POSIX shell). Windows has CMD (inherited from MSDOS) and PowerShell.

  • The way of interpreting commands is different (on Windows look also into PowerShell, which I don't know). On Unix it is the shell (not the invoked programs) that is expanding your command and globbing. See this answer for more. The notion of current working directory is different.

  • the operating system concepts are (slightly or significantly) different on Windows and on Unix or POSIX. For example, files, directories, processes, libraries are different (for example, a file can be written by a process and removed by another one on Unix and it can have several names on Linux thru hard links), .... etc.... You could read Operating Systems: Three Easy Pieces for an overview.

  • the Unix philosophy is not (always) applicable to Windows.

So you need to study Unix (or POSIX) and write your own shell script from scratch. Don't try to "translate" a bat script to a Unix shell script, but redesign it entirely (starting from the problem you want it to solve).

(and Wine or DosBox is not helpful in your case)

Read also about SCP and perhaps FTP. Perhaps using some distributed version control system like git could be relevant for you (e.g. to share scripts, source code, etc...).


If you need to run remotely some Windows .bat script on a distant Windows machine (e.g. from a Unix machine), you should use some remote command running service (that is, find and use some equivalent of SSH service on Windows, and use the corresponding client on Unix). See this.

So if you need to remotely run on a Windows server something (e.g. some program, some script, some command) from a Unix machine you should ask a different question (or at least improve a lot the current one).

Read about the client-server model and about application layer to use the correct terminology. You should name what protocol, server, client, service you want to involve. Nothing is magically "triggered" without using them.


PS. I'm using Unix since 1987, Linux since 1993. I never used Windows.

Basile Starynkevitch
  • 223,805
  • 18
  • 296
  • 547