cygwin bash shell script using ls problem

cygwin bash shell script using ls problem

am 25.08.2007 09:58:40 von moonhk

Hi All

How ls can not able to using in cygwin bash shell script ?

bash-3.2$ uname -a
CYGWIN_NT-5.1 moon 1.5.24(0.156/4/2) 2007-01-31 10:57 i686 Cygwin
bash-3.2$


#!/usr/bin/bash
echo "eric"
date "+%Y/%m/%d %H:%M:%S"
echo `date`
#
ls

bash-3.2$ ls1.ksh
eric
2007/08/25 15:53:22
Sat Aug 25 15:53:22 TST 2007
: No such file or directory
bash-3.2$

Re: cygwin bash shell script using ls problem

am 25.08.2007 16:40:49 von Ed Morton

moonhk wrote:

> Hi All
>
> How ls can not able to using in cygwin bash shell script ?
>
> bash-3.2$ uname -a
> CYGWIN_NT-5.1 moon 1.5.24(0.156/4/2) 2007-01-31 10:57 i686 Cygwin
> bash-3.2$
>
>
> #!/usr/bin/bash
> echo "eric"
> date "+%Y/%m/%d %H:%M:%S"
> echo `date`
> #
> ls
>
> bash-3.2$ ls1.ksh
> eric
> 2007/08/25 15:53:22
> Sat Aug 25 15:53:22 TST 2007
> : No such file or directory
> bash-3.2$
>

You probably have a non-printable control character at the end of the
line (perhaps due to using some Windows editor). Look:

$ ls
a
$ ls ^H
ls:: No such file or directory

Try a "cat -v" on your script. If that's not it, what do you get when
you run "ls" outside of the shell script?

Ed.

Re: cygwin bash shell script using ls problem

am 11.09.2007 10:13:55 von moonhk

On 8 25 , 10 40 , Ed Morton wrote:
> moonhk wrote:
> > Hi All
>
> > How ls can not able to using in cygwin bash shell script ?
>
> > bash-3.2$ uname -a
> > CYGWIN_NT-5.1 moon 1.5.24(0.156/4/2) 2007-01-31 10:57 i686 Cygwin
> > bash-3.2$
>
> > #!/usr/bin/bash
> > echo "eric"
> > date "+%Y/%m/%d %H:%M:%S"
> > echo `date`
> > #
> > ls
>
> > bash-3.2$ ls1.ksh
> > eric
> > 2007/08/25 15:53:22
> > Sat Aug 25 15:53:22 TST 2007
> > : No such file or directory
> > bash-3.2$
>
> You probably have a non-printable control character at the end of the
> line (perhaps due to using some Windows editor). Look:
>
> $ ls
> a
> $ ls ^H
> ls:: No such file or directory
>
> Try a "cat -v" on your script. If that's not it, what do you get when
> you run "ls" outside of the shell script?
>
> Ed.- -
>
> - -

Still can not.
bash-3.2$ ls.ksh
bash: /cygdrive/x/home/example/software/shell/ls.ksh: No such file or
directory
bash-3.2$ cat -v ls.ksh
/cygdrive/d/unixcommand/ls
bash-3.2$ pwd
/cygdrive/c/Documents and Settings/ericl6
bash-3.2$ cat ls.ksh
/cygdrive/d/unixcommand/ls
bash-3.2$

Re: cygwin bash shell script using ls problem

am 11.09.2007 14:59:59 von Ed Morton

moonhk wrote:
> On 8 25 , 10 40 , Ed Morton wrote:
>
>>moonhk wrote:
>>
>>>Hi All
>>
>>>How ls can not able to using in cygwin bash shell script ?
>>
>>>bash-3.2$ uname -a
>>>CYGWIN_NT-5.1 moon 1.5.24(0.156/4/2) 2007-01-31 10:57 i686 Cygwin
>>>bash-3.2$
>>
>>>#!/usr/bin/bash
>>>echo "eric"
>>>date "+%Y/%m/%d %H:%M:%S"
>>>echo `date`
>>>#
>>>ls
>>
>>>bash-3.2$ ls1.ksh
>>>eric
>>>2007/08/25 15:53:22
>>>Sat Aug 25 15:53:22 TST 2007
>>>: No such file or directory
>>>bash-3.2$
>>
>>You probably have a non-printable control character at the end of the
>>line (perhaps due to using some Windows editor). Look:
>>
>>$ ls
>>a
>>$ ls ^H
>>ls:: No such file or directory
>>
>>Try a "cat -v" on your script. If that's not it, what do you get when
>>you run "ls" outside of the shell script?
>>
>> Ed.- -
>>
>>- -
>
>
> Still can not.
> bash-3.2$ ls.ksh
> bash: /cygdrive/x/home/example/software/shell/ls.ksh: No such file or
> directory
> bash-3.2$ cat -v ls.ksh
> /cygdrive/d/unixcommand/ls
> bash-3.2$ pwd
> /cygdrive/c/Documents and Settings/ericl6
> bash-3.2$ cat ls.ksh
> /cygdrive/d/unixcommand/ls
> bash-3.2$
>

I'm guessing that your current directory (/cygdrive/c/Documents and
Settings/ericl6) is not in your PATH but
/cygdrive/x/home/example/software/shell is, so when you invoke "ls.ksh"
you're actually invoking /cygdrive/x/home/example/software/shell/ls.ksh
rather than /cygdrive/c/Documents and Settings/ericl6/ls.ksh as you expect.

Try invoking it as "./ls.ksh" and, again, tell us what happens when you
invoke "ls" from the command line.

Ed.

Re: cygwin bash shell script using ls problem

am 12.09.2007 06:23:05 von moonhk

On 9 11 , 8 59 , Ed Morton wrote:
> moonhk wrote:
> > On 8 25 , 10 40 , Ed Morton wrote:
>
> >>moonhk wrote:
>
> >>>Hi All
>
> >>>How ls can not able to using in cygwin bash shell script ?
>
> >>>bash-3.2$ uname -a
> >>>CYGWIN_NT-5.1 moon 1.5.24(0.156/4/2) 2007-01-31 10:57 i686 Cygwin
> >>>bash-3.2$
>
> >>>#!/usr/bin/bash
> >>>echo "eric"
> >>>date "+%Y/%m/%d %H:%M:%S"
> >>>echo `date`
> >>>#
> >>>ls
>
> >>>bash-3.2$ ls1.ksh
> >>>eric
> >>>2007/08/25 15:53:22
> >>>Sat Aug 25 15:53:22 TST 2007
> >>>: No such file or directory
> >>>bash-3.2$
>
> >>You probably have a non-printable control character at the end of the
> >>line (perhaps due to using some Windows editor). Look:
>
> >>$ ls
> >>a
> >>$ ls ^H
> >>ls:: No such file or directory
>
> >>Try a "cat -v" on your script. If that's not it, what do you get when
> >>you run "ls" outside of the shell script?
>
> >> Ed.- -
>
> >>- -
>
> > Still can not.
> > bash-3.2$ ls.ksh
> > bash: /cygdrive/x/home/example/software/shell/ls.ksh: No such file or
> > directory
> > bash-3.2$ cat -v ls.ksh
> > /cygdrive/d/unixcommand/ls
> > bash-3.2$ pwd
> > /cygdrive/c/Documents and Settings/ericl6
> > bash-3.2$ cat ls.ksh
> > /cygdrive/d/unixcommand/ls
> > bash-3.2$
>
> I'm guessing that your current directory (/cygdrive/c/Documents and
> Settings/ericl6) is not in your PATH but
> /cygdrive/x/home/example/software/shell is, so when you invoke "ls.ksh"
> you're actually invoking /cygdrive/x/home/example/software/shell/ls.ksh
> rather than /cygdrive/c/Documents and Settings/ericl6/ls.ksh as you expect.
>
> Try invoking it as "./ls.ksh" and, again, tell us what happens when you
> invoke "ls" from the command line.
>
> Ed.- -
>
> - -
Check PATH
X:\HOME\Example\Software\shell>split.ksh path | sort | uniq
/cygdrive/c/Perl/bin
/cygdrive/c/Perl/site/bin
/cygdrive/c/Program Files/Attachmate/Reflection/
/cygdrive/c/Program Files/Common Files/Teleca Shared
/cygdrive/c/Program Files/Java/jdk1.6.0_01/bin
/cygdrive/c/Program Files/Sybase/Shared/PowerBuilder
/cygdrive/c/Program Files/Sybase/Shared/Sybase Central 4.0/java
/cygdrive/c/Program Files/Sybase/Shared/Web Targets
/cygdrive/c/Program Files/Sybase/Shared/win32
/cygdrive/c/Program Files/Sybase/SQL Anywhere 7/win32
/cygdrive/c/Program Files/Symantec/pcAnywhere/
/cygdrive/c/Program Files/Windows NT/Accessories
/cygdrive/c/Sybase/BIN
/cygdrive/c/Sybase/DLL
/cygdrive/c/sybtools/ASEP
/cygdrive/c/sybtools/WIN32
/cygdrive/c/WINDOWS
/cygdrive/c/WINDOWS/system32
/cygdrive/c/WINDOWS/system32/WBEM
/cygdrive/d/eric_Shell
/cygdrive/d/unixcommand
/cygdrive/x/home/example/software/perl
/cygdrive/x/home/example/software/shell
/cygdrive/x/HOME/Example/Software/shell
/cygdrive/x/system
var=path

X:\HOME\Example\Software\shell>

X:\HOME\Example\Software\shell>ls.ksh
eric
2007/09/12 12:21:53
Wed Sep 12 12:21:53 CST 2007
ChkService.vbs cxleung.bat hello.vbs
rename_scanimage.vbs split.ksh
Desktop.ini directory.vbs history
sendmail.vbs system_desc.vbs
backup_notes.vbs driver.vbs lanuch_ie_tst.vbs
sendmail2.vbs test.pl
backup_notes2.vbs exp.bat ls.ksh
sendmail3_tst.vbs test.vbs
backup_notes_archive.ksh file_read.vbs ps.vbs
shell.bat tree.vbs
bar.vbs file_write.vbs rename_jpg.ksh
sleep.bat upfile.vbs

X:\HOME\Example\Software\shell>

X:\HOME\Example\Software\shell>bash ls.ksh
eric
2007/09/12 12:22:17
Wed Sep 12 12:22:17 CST 2007
ChkService.vbs cxleung.bat hello.vbs
rename_scanimage.vbs split.ksh
Desktop.ini directory.vbs history
sendmail.vbs system_desc.vbs
backup_notes.vbs driver.vbs lanuch_ie_tst.vbs
sendmail2.vbs test.pl
backup_notes2.vbs exp.bat ls.ksh
sendmail3_tst.vbs test.vbs
backup_notes_archive.ksh file_read.vbs ps.vbs
shell.bat tree.vbs
bar.vbs file_write.vbs rename_jpg.ksh
sleep.bat upfile.vbs

X:\HOME\Example\Software\shell>

X:\HOME\Example\Software\shell>bash
bash-3.2$ ls.ksh
bash: /cygdrive/x/home/example/software/shell/ls.ksh: No such file or
directory
bash-3.2$ ./ls.ksh
bash: ./ls.ksh: No such file or directory
bash-3.2$

Re: cygwin bash shell script using ls problem

am 12.09.2007 17:29:36 von Glenn Jackman

At 2007-09-12 12:23AM, "moonhk" wrote:
> X:\HOME\Example\Software\shell>ls.ksh
[... ok ...]
>
> X:\HOME\Example\Software\shell>bash ls.ksh
[... ok ...]
>
> X:\HOME\Example\Software\shell>bash
> bash-3.2$ ls.ksh
> bash: /cygdrive/x/home/example/software/shell/ls.ksh: No such file or
> directory
> bash-3.2$ ./ls.ksh
> bash: ./ls.ksh: No such file or directory
> bash-3.2$

It seems obvious that either your $PATH or pwd (or both) change when you
launch an interactive bash shell. What do you do in your ~/.bashrc ?
Or read the bash man page (the "INVOCATION" section) to see what other
files may get sourced in an interactive shell.


--
Glenn Jackman
"You can only be young once. But you can always be immature." -- Dave Barry