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 ...)."
methyl
July 23, 2010, 11:12am
3
What do you want the script to do?
aigles
July 23, 2010, 12:54pm
4
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.
methyl
July 23, 2010, 1:03pm
5
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...
---------- 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.
@aigles ,
I want to know the usage of the commands given by you..
type -a sh
set | grep ENV=
aigles
July 26, 2010, 11:00am
7
type -a sh
this command display how the command sh is inpterpreted.
From bash man page :
type [-aftpP] name [name ...]
With no options, indicate how each name would be interpreted if used as a
command name. If the -t option is used, type prints a string which is one
of alias, keyword, function, builtin, or file if name is an alias, shell
reserved word, function, builtin, or disk file, respectively. If the name
is not found, then nothing is printed, and an exit status of false is
returned. If the -p option is used, type either returns the name of the
disk file that would be executed if name were specified as a command name,
or nothing if ``type -t name'' would not return file. The -P option forces
a PATH search for each name, even if ``type -t name'' would not return file.
If a command is hashed, -p and -P print the hashed value, not necessarily
the file that appears first in PATH. If the -a option is used, type prints
all of the places that contain an executable named name. This includes
aliases and functions, if and only if the -p option is not also used. The
table of hashed commands is not consulted when using -a. The -f option sup
presses shell function lookup, as with the command builtin. type returns
true if any of the arguments are found, false if none are found.
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 .....
set | ENV=
This command did not return anything ,,.. might be because am using a offline UNIX emulator ????
Can you tell me a sample output of this command.? ...
aigles
July 27, 2010, 4:14am
9
Just an example :
$ set | grep ENV=
BASH_ENV=/home/Jp/.my_bash.env
ENV=/home/Jp/.my_sh.env
$
Jean-Pierre.