Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When I am trying to execute a file( in the command line by the command ./ , I am getting the error that:

"." is not recognized as an internal or external command, operable or batch file

please help me execute the .sh file

share|improve this question

migrated from Mar 15 '10 at 8:36

This question came from our site for professional and enthusiast programmers.

12 Answers 12

You're on Windows CMD.EXE (from the error message). It uses a different syntax to execute commands. You'll need to use sh, assuming that you've got Cygwin or similar installed.

To clarify, Windows does not have a built-in utility to support .sh files. To run such, you'll need to install a third-party tool such as Cygwin.

share|improve this answer
Could you also not just install Git on Windows? It seems that doing so adds support for shell scripts even if those shell scripts are not performing Git-related tasks. – DavidB Dec 12 '14 at 1:31
@DavidB Yes, that works if you put C:\Program Files (x86)\Git\bin (or whatever it is on your computer) in your PATH, because Git places all sorts of useful tools there including sh.exe – Sumyrda Jun 23 at 13:55

You are trying to run a Linux command at the Windows Command Prompt.

On Linux the forward slash is a path separater. On Windows the backslash is a path separator and the forward slash generally indicates an argument.

Therefore, Windows thinks you are trying to run a command called "." and parsing it the argument "/". The correct convention would be ".\". Additionally Windows will automatically search the current directory for your command so you could just type "".

The next problem you will face is that Windows does not know what a sh script is, again this is a Linux thing. You could solve this by installing Cygwin if you really want or need to run a sh script.

However, judging by one of your previous comments you could just as well rename the script to name.bat and delete the "#!/bin/sh" line. Now you have a Batch file which Windows should understand. You can read more about batch files here.

share|improve this answer

Alternatively you could turn to the dark side and install Linux. From the prompt:



sudo sh

Your program will run and you will have a better system as well.

share|improve this answer
That's like saying, " Just get rich and pay someone to do it for you " – Funkodebat Sep 16 '15 at 0:52

Windows doesn't natively run .sh. shell scripts. Have you installed something like CygWin, or are you just trying to run it natively in cmd.exe?

share|improve this answer

You're trying to run your car on orange juice instead of gasoline. Windows shares similar commands stored in .bat or .cmd files with Unix/Linux/zOS Unix Subsystem/*ix shell scripts as these two families of operating systems share a common ancestor the DEC PDP-x machines.

If you want instant gratification, you will need to install an environment that provides a "sh.exe" program or "csh.exe" or "bash.exe" program (tsh.exe anyone?)

Alternatively, if you know Unix script commands, very well, and you know Windows .cmd and .bat file commands, very well, you can translate the .sh file into a .bat or .cmd file. Even so, you will often encounter more Unix-styled programs that have no equivalent under Windows--grep, sed, vi, emacs, etc. Thus, the call to install CygWin (no minimalist)--just to get the shell and Unix tools. Put it on a flash-drive, for these special occasions.

share|improve this answer

Someone said something about MS-DOS using / for commands and \ for paths. This is slightly misleading. Look at my example:


Has no difference in effect. Yes, it is not true for all operations – the actual answer is simply No, or without Cygwin or SSHD you can't.

I only know because I stupidly spent half a day trying to figure out what if then fi and eval, exec do with -Djava.something when called.

share|improve this answer

Use Github for Windows. It contains all the Unix environment executables.

share|improve this answer
More specifically, install Git. The only reason installing Github for Windows contains a Bash shell is because it comes with Git. :) – ZaLiTHkA Nov 19 '15 at 0:37
Good alternative, thanks, so do not need to be installing more tools. +1 – Guilherme Nascimento May 3 at 14:50

It's possible that the problem is actually within the file -- you are trying to use the . command but it is attempting to run a kind of shell (e.g., csh, I think) in which that's not a valid command.

So: does start with the correct #!/bin/sh (if you are actually trying to run sh)?

share|improve this answer
yes it does start #!/bin/sh cd D:\Raghu D: winzip32.exe -min -a -r D:\p thats the content of the file – sushant Mar 15 '10 at 8:12

If you have a Linux box in your home (or work) and plugged to the same network, and this network is safe, this might do the trick:

  1. Make a folder share on Windows (pretty easy, but make sure the network is safe from intruders).
  2. Mount it in Linux with mount //WinMachine/Share LinuxFolder (IIRC, and requires Samba).
  3. Using something like PuTTY, log in remotely to that Linux box.
  4. Run your command in the mounted folder.
share|improve this answer

To run the shell script from the windows. First use the command : dos2unix then you can use your normal command : sh

This will work out.

share|improve this answer
Sorry, slight correction needs to be done. Use the command : "dos2unix" Output: dos2unix: converting file to UNIX format then you use your command: "sh" This will surely run you shell script. Happy learning – Sridhar GV Nov 23 '15 at 12:02
question was not about file format, but rather about lack of shell in windows. – Archemar Nov 23 '15 at 13:48

ok, there's a LOT wrong with that - drop the #!/bin/sh, and change the extention to bat, and it might work with a few more fixes. Then you can just invoke it by its filename as well.

The syntax of a unix shell script, and a windows batch file arn't too similar. cygwin, or a load of messing around with unxutils might make something that would work in both, but unless you're ABSOLUTELY sure the environment is always the same, it isn't worth the headache

share|improve this answer
drop the #!/bin/sh, and change the extention to bat, and it might work with a few more fixes. What?! I suspect you never tried this... On Windows, even the simpliest bash capabilities are unsupported or require lengthy syntax. – Camilo Martin Aug 31 '12 at 14:29
The second paragraph covers the fact that its likely to not work, without a fair amount of work. – Journeyman Geek Aug 31 '12 at 15:09
Well, you're right. – Camilo Martin Aug 31 '12 at 15:11

I found a different and easy solution, called UnixUtil.

Download and unzip it to C: drive. Set the environment variable path to include C:\UnixUtils\usr\local\wbin.

This is important. DO NOT set path to C:\UnixUtils\bin

share|improve this answer

You must log in to answer this question.