cygwin bash shell script using ls problem

  • Follow


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$

0
Reply moon_ils-se (53) 8/25/2007 7:58:40 AM

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.
0
Reply Ed 8/25/2007 2:40:49 PM


On 8 25 ,   10 40 , Ed Morton <mor...@lsupcaemnt.com> 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$

0
Reply moonhk 9/11/2007 8:13:55 AM

moonhk wrote:
> On 8 25 ,   10 40 , Ed Morton <mor...@lsupcaemnt.com> 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.
0
Reply Ed 9/11/2007 12:59:59 PM

On 9 11 ,   8 59 , Ed Morton <mor...@lsupcaemnt.com> wrote:
> moonhk wrote:
> > On 8 25 ,   10 40 , Ed Morton <mor...@lsupcaemnt.com> 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$

0
Reply moonhk 9/12/2007 4:23:05 AM

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
0
Reply Glenn 9/12/2007 3:29:36 PM

5 Replies
71 Views

(page loaded in 0.263 seconds)


Reply: