Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Win32 gawk vs. Unix awk

by gibsonca (Beadle)
on Nov 23, 2009 at 23:59 UTC ( #808966=perlquestion: print w/ replies, xml ) Need Help??
gibsonca has asked for the wisdom of the Perl Monks concerning the following question:

Ultimately I want to convert about 5 gawk/awk scripts to perl, but right now just trying to understand what I percieve as a difference between gawk (version 3.1.6) and sun unix awk. (Using or not using perl does not affect the problem.)

$cmd = "gawk -f D:\\tools\\scan_tdf.awk corrtype=ada FileSuffix=_pkg TDFname=sys_mma_pfd_gmeter.tdf PrefixFile=d:\\tools\\PrefixFile BusNamesFile=d:\\data\\ssi_BusNames VAXPATH=NONE DIRPATH=def"; print "cmd is $cmd \n"; $sts = system($cmd);

On the sun unix side the variables are getting passed through and processed, while on the DO$ side they are not. For example corrtype is set to "ada" on sun unix side, while on the DOS side corrtype is not set or defined. Any help appreciated.

Comment on Win32 gawk vs. Unix awk
Download Code
Re: Win32 gawk vs. Unix awk
by ikegami (Pope) on Nov 24, 2009 at 00:02 UTC
    Windows command lines cannot have newlines in them.

    Better approach, especially for unix:

    my @cmd = ( gawk => ( -f => 'D:\\tools\\scan_tdf.awk', 'corrtype=ada', 'FileSuffix=_pkg', 'TDFname=sys_mma_pfd_gmeter.tdf', 'PrefixFile=d:\\tools\\PrefixFile', 'BusNamesFile=d:\\data\\ssi_BusNames ', 'VAXPATH=NONE', 'DIRPATH=def', ) ); $sts = system { $cmd[0] } @cmd;

      On the DOS side, things are still not working like UNIX. gawk (GNU Awk 3.1.6) is calling the scan_tdf.awk file, but none of the values like corrtype are being passed over. The files are the same between UNIX and DOS.

      $cmd = "gawk -f D:\\tools\\scan_tdf.awk 'corrtype=ada', 'FileSuffix=_p +kg', 'TDFname=sys_mma_pfd_gmeter.tdf', 'PrefixFile=d:\\tools\\PrefixF +ile', 'BusNamesFile=d:\\data\\ssi_BusNames', 'VAXPATH=NONE', 'DIRPATH +=NONE'"; print "cmd1 is $cmd \n\n"; $sts = system($cmd); print "sts1 from gawk is $sts \n"; exit(0);

      Still looking for help!

      I have tried modifying the calling parameters in many ways...

        So I solved this little DOS GNU gawk problem by using the "-v" argument. Everything now works like UNIX. Back to converting this to perl. ;-)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://808966]
Approved by broomduster
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (16)
As of 2014-09-17 18:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (95 votes), past polls