invoking perl inside a ksh script
Can anyone help with this?
Trying to invoke perl inside ksh script. #!/usr/bin/ksh tm=72392 /bin/perl -e $epochseconds="$tm"; ($second, $minute, $hour) = gmtime($epochseconds); print sprintf("%02d:%02d:%02d\n", $hour, $minute, $second); Thanks in advance for your help .. |
On my system:
Code:
~$ which perl |
Quote:
You're not saying in which way this fails, but one problem is that the '' that normally wrap a '-e' command are missing. Code:
#!/usr/bin/ksh Cheers, Tink |
Hi.
Similarly: Code:
#!/usr/bin/env bash Code:
./s3 |
This is for awk (nawk) but equally valid for perl, sed, etc...
The normal way is to use Single Quotes.... nawk '# output to mailx commands! /^[^ ]/ { recipent=$0; } /^ / { print $0 > "|mailx -s \"This is the test\" " recipent; } /^$/ { close( "|mailx -s \"This is the test\" " recipent ); ' list.txt Note the whole script is inside single quotes on the nawk command line! ASIDE: old versions of awk must have something on the first line thus the addition of the # comment to keep it happy! Perl needs no such comment but does require a -e option to execute a command line argument. To insert a external shell variable into the script you need to close the single quotes, output variable and re-open the single quotes. Also the variable sould be in double quotes so as to prevent any insertion of space characters, and depending on situation double quotes inside the awk script too. Example inserting a $prefix shell variable into a awk string. ' ... { print "'"$prefix"'" $0; } ... ' Also to insert a single quote into the script you have to also exit the wrapping single quotes and supply it outside those quotes ' ... { print "I just can'\''t do that!"; } ... ' CAUTION: Watch for single quotes inside any COMMENTS which is in the script! Comments are within the single quotes so are also scanned for those quotes. I have used that technique to wrapper very large perl scripts inside even larger shell scripts. |
All times are GMT -5. The time now is 05:55 AM. |