Link to home
Start Free TrialLog in
Avatar of veedar
veedarFlag for United States of America

asked on

Scripts in Cygwin acting strangely

Bash scripting in my Cygwin environment that used to work so well is now acting strangely.

To illustrate see how variable $i works with echo but fails with ls, given a file like this...
$ cat /tmp/psif
pointsec
pointsec/docs
pointsec/docs/Architecture.doc

And a script like this...
$ cat /tmp/ww
#!/usr/bin/bash -x
for i in `cat /tmp/psif`
do
echo $i
ls -dl $i
read x
done

When I run it with -x for debgging I get this....
$ /tmp/ww
++ cat /tmp/psif
+ for i in '`cat /tmp/psif`'
+ echo $'pointsec\r'
pointsec
+ ls -dl $'pointsec\r'
: No such file or directory
+ read x

+ for i in '`cat /tmp/psif`'
+ echo $'pointsec/docs\r'
pointsec/docs
+ ls -dl $'pointsec/docs\r'
: No such file or directorydocs
+ read x

+ for i in '`cat /tmp/psif`'
+ echo $'pointsec/docs/Architecture.doc\r'
pointsec/docs/Architecture.doc
+ ls -dl $'pointsec/docs/Architecture.doc\r'
: No such file or directorydocs/Architecture.doc
+ read x

Anyone have an idea what's going on?
Avatar of MikeOM_DBA
MikeOM_DBA
Flag of United States of America image


Yes, the directory you are trying to 'ls' does not exist in the path from wich you are executing the script.

"No such file or directory docs/Architecture.doc"

Avatar of veedar

ASKER

I wish it was that easy...they do exist...

$ ls -ld pointsec pointsec/docs pointsec/docs/Architecture.doc
drwxr-xr-x+ 4 veedar Domain Users      0 Mar 19 13:30 pointsec
drwxr-xr-x+ 2 veedar Domain Users      0 Mar 16 10:48 pointsec/docs
-rwxr-xr-x  1 veedar Domain Users 128512 Mar 13 10:37 pointsec/docs/Architecture.doc
ASKER CERTIFIED SOLUTION
Avatar of amit_g
amit_g
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of veedar

ASKER

Thanks amit_g dos2unix fixed it.  I thought I had already checked for a DOS issue but I guess not.