When I am trying to execute a file(name.sh) in the command line by the command ./name.sh , 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

link|improve this question
1  
Your question will soon be migrated to superuser.com, where you will receive better answers. I've edited your question for formatting and content to help ensure that you get the answer that you want. – Tim Post Mar 15 '10 at 8:03
feedback

migrated from stackoverflow.com Mar 15 '10 at 8:36

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

9 Answers

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

link|improve this answer
5  
Perhaps to add a clarification. Windows does not have a built in utility to support .sh files and you need to install a third party tool such as Cygwin to run .sh files. – BBlake Mar 15 '10 at 12:52
feedback

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?

link|improve this answer
feedback

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 "/name.sh". The correct convention would be ".\name.sh". Additionally Windows will automatically search the current directory for your command so you could just type "name.sh".

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.

link|improve this answer
feedback

It's possible that the problem is actually within the file name.sh -- 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 name.sh start with the correct #!/bin/sh (if you are actually trying to run sh)?

link|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
feedback

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

link|improve this answer
feedback

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

sh runide.sh

or

sudo sh runide.sh

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

link|improve this answer
feedback

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.

link|improve this answer
feedback

I was on a train when looking at this post... Someone said something about MS-DOS using / for command and \ for path...this is slightly misleading...look at my example

C:\myfoo\foo>cd../.. C:\myfoo\foo>cd....

Has no difference in effect...YES it is not true for all operations....the actual answer is simply NO..,ot without Cygwin or sshd you cannot...

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

Hope this answers the question

link|improve this answer
feedback

What Eimantas said or use

sh name.sh
link|improve this answer
i tried sh name.sh and chmod u+x name.sh, but its not recognizing these commands too. do i need to enable shell scripting somewhere? – sushant Mar 15 '10 at 8:10
feedback

Your Answer

 
or
required, but never shown