Greg Ercolano wrote:
Andrew Kingston wrote:
I've just been doing a bit more digging & I think I've found what was
causing the problem. In \cygwin\bin if you do an ls -l awk.exe, it
gives you: lrwxrwxrwx 1 Adminst Users 19 Nov 1 2004 awk.exe -> gawk.exe.
Huh, I didn't know cygwin somehow implemented symbolic links
under Windows.
Maybe underneath it's a 'junction'.. Windows terminology
for a symlink, which Win32 does support, but junctions can
only be pointed to files on the same disk currently, not to
network drives :/
More info about NTFS junctions here:
http://support.microsoft.com/default.aspx?scid=kb;EN-US;q205524
If I run gawk.exe at a DOS prompt I don't get any errors, but run
awk.exe, and I get the error I've been mentioning.
Weird.
It's as if the cygwin symbolic link is the cause.
Yep. I'm not how Cygwin implements it, but it emulates mounts and
links. Apparently any program using linked files will not run properly
if started outside of Cygwin. I can't even list the links from a DOS
prompt using dir - but they do list if I use the /as switch on dir...
I get the same error whenever I try to run one of the linked Cygwin
apps at a DOS prompt - like gunzip.exe & zcat.exe.
If you're curious, it might be interesting to make it a copy
instead of a link, eg:
cp gawk.exe /temp/awk.exe
echo 4 | /temp/awk '{ printf("%04d\n"; }'
..the implication being if that works, it's the symlink for sure.
Might be a bug in the specific version of cygwin you're using.
I tried cygwin once, and it was too weird for me. It has too
many hoops it hops through with those weird pathnames it uses,
and some of its shells are kinda buggy. So I left it alone,
and decided to just do everything in perl, and just live with
DOS as an interactive shell. DOS has been getting better;
things like tab completion and better commands make it less
annoying than it used to be.
I don't think it's a bug as it is possible to use awk if started from
Cygwin, just not if started from DOS - though if I start the submit
script I was getting the original errors with, from a Cygwin shell, I
still get the same error... I don't use Cygwin a lot myself either for
the same kind of reasons. I do use cwRsync though (a kind of standalone
package of Cygwin Rsync) - very useful for backing up data from windows
workstations. I tried what you suggested above (copying gawk) & it
worked as expected, so it does seem to be a symlink issue.
So it looks like I could put the code back into my script if I needed
to as long as I used gawk instead of awk.
Yes -- I'd agree.
It's good you got to the bottom of that; we can all know
to watch for this.
FWIW, within your perl script, you should be able to do
all awk-like stuff within perl, eg. these being equivalent:
echo 4 | awk '{ printf("%04d\n",$0); }'
echo 4 | perl -ne '{ printf("%04d\n",$_); }'
..or better yet, just use perl to do the work.
I can't think of any situation where one would
need a perl script to invoke awk externally.. it's
usually always more efficient to code it all within perl.
Agreed - I'm also much more comfortable using perl, so if I needed to
replace my colleagues code I'd do that... as long as I could work out
what he was trying to do with awk :)
eg. I'd always prefer these perl commands:
my $padframe = sprintf("%04d", $frame);
..to these:
my $padframe = `echo $frame | awk '{ printf("%04d\n",$0); }'`;
chomp($padframe);
|