Cygwin-shell script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Cygwin-shell script
# 1  
Old 07-23-2010
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.

Code:
grep echo *

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

IP.sh
Code:
echo "Starting command..........."
grep echo *

Execution details:
Code:
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!

Last edited by Scott; 07-23-2010 at 12:15 PM.. Reason: Please use code tags
# 2  
Old 07-23-2010
man grep:

"grep searches the named input files (or standard input if no files are named ...)."
# 3  
Old 07-23-2010
What do you want the script to do?
# 4  
Old 07-23-2010
Modify your IP.sh to check that you run in the right place :
Code:
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 ?
Code:
type -a sh
set | grep ENV=


Jean-Pierre.
# 5  
Old 07-23-2010
Are there filenames in the directory which contain space characters?
# 6  
Old 07-26-2010
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
Code:
sh is /usr/bin/sh
sh is /bin/sh

Can you please tell me , about this.

Code:
set | grep ENV=

The problem is not yet solved... Smilie

---------- 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. Smilie

@aigles,

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

Code:
type -a sh
set | grep ENV=


Last edited by flamingo_l; 07-26-2010 at 02:46 AM..
# 7  
Old 07-26-2010
Code:
type -a sh

this command display how the command sh is inpterpreted.
From bash man page :
Quote:
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.
Code:
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.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Execute a shell script in UNIX server from Cygwin

Hi All, We have shell scripts in UNIX ( Sun OS ) server. Also in my windows machine i have Cygwin installed. Now is there a way to execute Shell script available in UNIX server from Cygwin? (4 Replies)
Discussion started by: Girish19
4 Replies

2. Shell Programming and Scripting

Running q-shell commands( on IBM-i Series) from cygwin terminal (on windows)

I have cygwin installed on windows server and when I do echo $SHELL the output is /bin/bash I have created a ssh tunnel from this windows server through cygwin to ibm -i series which is running Q-shell. I am trying to invoke a utility wsadmin (used for scripting) on ibm-i from the... (12 Replies)
Discussion started by: gaurav99
12 Replies

3. Shell Programming and Scripting

Cygwin shell script

I have a file with below format : 2013-05-20 hello has done 2013-05-20 hi 000abc abc 2013-05-21 thank you I want the out put to be like this : 2013-05-20 hello has done 2013-05-20 hi 000abc abc 2013-05-21 thank you What I could think of is something like this : cat... (7 Replies)
Discussion started by: Sparta
7 Replies

4. Shell Programming and Scripting

cygwin executable shell scripts

Hello, Cygwin will execute a shell script without turning on executable status on the file. I want to force cygwin to be more like linux and not execute scripts directly on the command line unless changing mode to have executable status. Is this possible? Thanks Larry (2 Replies)
Discussion started by: larrye0123
2 Replies

5. Shell Programming and Scripting

Running shell script in Cygwin terminal

I am new to shell scripting. I tried to run a simple shell script using Cygwin terminal in Win XP env. The script I have written is as follows - #!/bin/bash a=5 ] && echo "true" || echo "false" But when I execute the script, getting some confusing error. The error I am getting are - ... (3 Replies)
Discussion started by: linux_learner
3 Replies

6. Shell Programming and Scripting

opening new instance of cygwin from withing cygwin

I'm using cygwin on win7, What I would like to do is something like this: cygstart cygwin tail -f /foo/test.log | perl -pe 's/error/\e I know I can start a new instance using either of these: mintty -e ... cygstart tail ... But neither of those open in ANSI mode, so I can't do... (0 Replies)
Discussion started by: Validatorian
0 Replies

7. Shell Programming and Scripting

cygwin shell script error

Hi, I have a cywin test script as below but errors, #!/usr/bin/bash while do echo "123" echo "456" done sh-3.2$ ./test.sh ./test.sh: line 7: syntax error: unexpected end of file Please help... Thanks! Victor (3 Replies)
Discussion started by: victorcheung
3 Replies

8. Shell Programming and Scripting

Execute a shell with cygwin

Hi everybody, I would like to execute a shell in windows. So I installed Cygwin but I got this message : $ sh /neuf.sh start % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 ... (4 Replies)
Discussion started by: mytrax
4 Replies

9. UNIX for Dummies Questions & Answers

Cygwin shell not coming up

Hi, I installed Cygwin y'day on Win XP SP2. The install went fine but when I clicked on Cygwin's shortcut to invoke its shell, it didn't come up.....was just opening for a fraction of second and then closed. Can anyone please advise? Regards er_ashu (6 Replies)
Discussion started by: er_ashu
6 Replies

10. UNIX for Dummies Questions & Answers

Problem with scheduling a shell script on cygwin using cron

Hi, Before I start, I would like to inform that, I went through all FAQs and other threads before posting here. I 'm trying to schedule a shell script on cygwin using cron. No matter what I do I don't seem to get the cron job executing my bash script. My script is temp.sh echo `date` >... (4 Replies)
Discussion started by: shash
4 Replies
Login or Register to Ask a Question