Cygwin-shell script

hi,

I am using Cygwin for running the shell script.

If i execute the following command at the prompt output is obtained.

grep echo *

The same i have put in a file and when am trying to execute it is throwing error.

IP.sh

echo "Starting command..........."
grep echo *

Execution details:

sh -vx IP.sh
 
echo "Starting command..........."
' echo 'Starting command...........
Starting command...........
grep echo *
' grep echo '*
: No such file or directory
echo $?
+ echo $'2\r'
2
exit $?
+ exit 0

Can anybody please help me on this!

man grep:

"grep searches the named input files (or standard input if no files are named ...)."

What do you want the script to do?

Modify your IP.sh to check that you run in the right place :

pwd
echo 
"Starting command..........."
grep echo *

Does the problem persist when running your script with bash instead of sh ?

What is the result of the commands ?

type -a sh
set | grep ENV=

Jean-Pierre.

Are there filenames in the directory which contain space characters?

I want the script to grep the word echo in the directories as well as subdirectories.

@Methyl, there are no files names in the directory which contains spaces.

@aigles,
when i give "type -a sh", output is

sh is /usr/bin/sh
sh is /bin/sh

Can you please tell me , about this.

set | grep ENV=

The problem is not yet solved... :frowning:

---------- Post updated at 09:33 AM ---------- Previous update was at 12:34 AM ----------

Now am able to execute the script. Thanks for all your replies. :slight_smile:

@aigles,

I want to know the usage of the commands given by you..

type -a sh
set | grep ENV=
type -a sh

this command display how the command sh is inpterpreted.
From bash man page :

set | ENV=

Display environment variables whith name ending with ENV.
See INVOCATION section of the bash man pages.

How have you fixed your problem ?

Jean-Pierre.

I have used notepad in windows to write my script since i was using Cygwin. That created ^M characters at the end of each line. When i wrote my script using Text pad it worked ..... :slight_smile:

set | ENV=

This command did not return anything ,,.. might be because am using a offline UNIX emulator :frowning: ????

Can you tell me a sample output of this command.? ...

Just an example :

$ set | grep ENV=
BASH_ENV=/home/Jp/.my_bash.env
ENV=/home/Jp/.my_sh.env
$

Jean-Pierre.

Thank you aigles