- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: Date Calculation Failed
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-21-2007 08:18 AM
тАО05-21-2007 08:18 AM
I have used caljd.sh many times with no problems but today when I tried to use it, it produced this error.
$ caljd.sh -S "-" -o -e 2454250
./caljd.sh: line 129: typeset: -Z: invalid option
typeset: usage: typeset [-afFirtx] [-p] name[=value] ...
./caljd.sh: line 131: typeset: -Z: invalid option
typeset: usage: typeset [-afFirtx] [-p] name[=value] ...
./caljd.sh: line 137: typeset: -Z: invalid option
typeset: usage: typeset [-afFirtx] [-p] name[=value] ...
awk: cmd. line:3: while ((knt < 4) && "locale LC_TIME 2>/dev/null" | \c
awk: cmd. line:3: ^ backslash not last character on line
00--0000
I also tried it with a newer version and get the same error.
Any ideas?
Thanks,
David
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-21-2007 08:29 AM
тАО05-21-2007 08:29 AM
Re: Date Calculation Failed
Perhaps you fetched a new version from the ITRC; saved in on a Windows platform and FTP'd it in binary mode to a Unix server. In that case, you have linefeed+carriage-return characters instead of simple linefeeds as your line delimiters.
If you do 'cat -etv file' you will see:
^M$
at the line's termination.
If this is the case, eliminate the carriage returns with:
# dos2ux caljd.sh > caljd.sh.new
# mv caljd.sh.new caljd.sh
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-21-2007 08:30 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-21-2007 08:40 AM
тАО05-21-2007 08:40 AM
Re: Date Calculation Failed
Thanks for replying but I was careful to download the script.
Hi ACS:
I am trying to run under bash but that was after it did not work under ksh. I got this output when I tried the same values under ksh.
$ caljd.sh -S "-" -o -e 2454250
00--0000
I will try the perl version but I would really like to fix the shell version.
Thanks,
David
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-21-2007 08:51 AM
тАО05-21-2007 08:51 AM
Re: Date Calculation Failed
In any event, caljd.pl will work in Linux (or Windows for that matter) and that is what I consider to be the portable caljd.xx version.
Most bash implementations fail with this construct:
echo "Stupid Bash" | read A B
echo "A = \"${A}\""
echo "B = \"${B}\""
${B} will be NULL rather than "Bash". You bash boys can argue about lvalues and subprocesses but this is a handy feature for parsing data.
Bash also does not know about "Z" (Zero-padded) variables.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-21-2007 09:20 AM
тАО05-21-2007 09:20 AM
Re: Date Calculation Failed
Yes, I am running redhat linux :(. Is there any way to fix caljd.sh to work on Linux?
Thanks,
David
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-21-2007 09:36 AM
тАО05-21-2007 09:36 AM
Re: Date Calculation Failed
Well, you now have learned that a shell comes in many flavors and a script written for one insn't necessary portable to under without some work.
As Clay noted, use his Perl version. That will work without any effort on your part!
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-21-2007 09:58 AM
тАО05-21-2007 09:58 AM
Re: Date Calculation Failed
To add: In fact, I submit that Clay should STOP parallel enhancements to caljd.sh and caljd.pl and only provide NEW features in caljd.pl [ assuming that anything is left of the alphabet :-) ]. In that fashion, this my-shell-ain't-your-shell nonsense would cease!
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-21-2007 10:16 AM
тАО05-21-2007 10:16 AM
Re: Date Calculation Failed
I will say that under Linux zsh is the least evil shell that I have found. Caljd.sh should work under zsh with one change: there is a line inside the AWK() function, "readonly AWKEXE". Comment out that line and zsh should work. Linux has a number of other 'improvements' such as the echo command. By default, echo "Test \c" outputs "Test \c
echo "Stupid Bash" | read A B problem ("feature" if you are a bash guy) but Perl sounds like a whole lot easier answer.
After all, you don't have to know anything about Perl to use caljd.pl, just replace ".sh" in your scripts which call caljd.sh with ".pl" and declare victory.
One thing I will say with absolute confidence is that no version of caljd.sh that I write will ever run under csh.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-22-2007 09:45 AM
тАО05-22-2007 09:45 AM
Re: Date Calculation Failed
In any event, if a stupid shell is detected which does not correctly (and I get to define 'correctly') handle
echo "Stupid Bash" | read A B
then I execute
echo "Stupid Bash" > tempfile
read A B < tempfile
instead.
Similarly, if a stupid shell is detected which does not execute
echo "Stupid Bash\c"
correctly, I assert a shell option which changes the behavior of echo.
I also removed all references to "typeset -Z" because not all shells support -Z (zero-padded) variables. Instead, I call a function to do the padding.
I had already addressed a problem under Solaris. For some reason, Sun missed the memo about 20 years ago that nawk (new awk) could be renamed or linked to awk. For anyone wanting to use the original awk, oawk (old awk) is still available. In any event, if nawk is in the PATH, it will be used otherwise awk will be used.