1826664 Members
2393 Online
109696 Solutions
New Discussion

Re: caljd.sh question

 
SOLVED
Go to solution
tikual
Advisor

caljd.sh question

When I try the script in SUN platform, it shows the error like this:
kit:149>./caljd.sh
awk: syntax error near line 3
awk: bailing out near line 3
0

I also tried sh -x caljd.sh and the error is like this:
caljd.sh: syntax error at line 285: 'Y_TARGET_DAY=$' unexpected

But I can run this script in Linux and HP platform successfully. Do anyone know the reason?

Thanks!
7 REPLIES 7
V.Tamilvanan
Honored Contributor

Re: caljd.sh question

Can u post the script
tikual
Advisor

Re: caljd.sh question

ops....there is a famous script from Clay. You can find it from this forum.
A. Clay Stephenson
Acclaimed Contributor
Solution

Re: caljd.sh question

1) Make sure that you download caljd.sh Vrsn 2.1. It will use nawk rather than awk if available.


2) Change the "shebang" at the top of the script from #!/usr/bin/sh to #!/usr/bin/ksh.


----------------------------

Plan B. Find and download caljd.pl. The arguments are exactly the same.


If it ain't broke, I can fix that.
Patrick Wallek
Honored Contributor

Re: caljd.sh question

Clay is right on the money, of course.

But if you have an earlier version of caljd.sh, you can go through the script and change all occurrences of awk to nawk.

That combined with the shell change to ksh, as Clay mentioned, should allow you to run it successfully on Sun platforms.
tikual
Advisor

Re: caljd.sh question

Both of you are really so great! The problem was solved. But, what is the different between awk and nawk?? How it works to solve my problem? Thanks!
V.Tamilvanan
Honored Contributor

Re: caljd.sh question


Hi,
With original awk, you can:??? Think of a text file as made up of records and fields in atextual database.??? Perform arithmetic and string operations.??? Use programming constructs such as loops conditionals.??? Produce formatted reportsWith nawk, you can also:??? Define your own functions??? Execute Unix commands from a script??? Process the results of Unix commands??? Process command-line arguments more gracefully??? Work more easily with multiple input streams??? Flush open output files and pipes (latest Bell Labs awk)In addition, with GNU auk (gawk), you can:??? Use regular expressions to separate records, as well asfield??? Skip to the start of the next file, not just the next record??? Perform more powerful string sustitutions??? Retrieve and format system time values
V.Tamilvanan
Honored Contributor

Re: caljd.sh question

Hi,
One more :-
Note that the most up to date version of Awk is called nawk. It is used in exactly the same way as awk but is a little more powerful - for example, it is capable of handling slightly larger strings as variable values - 3000 characters instead of 2500. The casual user is unlikely to be inconvenienced by such restrictions of awk. All programs in these notes should run equally well with either awk or nawk. On some machines, nawk may be the default and and be invoked with the usual awk command. You can always check this with the which awk/nawk command.