Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Have you tried breaking up the commands in the script up and using echo statements (and use /bin/bash -x as the interpreter) to see what each step is returning? The individual commands look OK, although I'd use the following to grep the output:
Wow, two posts in less than an hour! Tangle the ntp command worked great. gilead, I'm a bit confused about the individual commands and echo part, but here's what I get running the commands individually then adding the next command to the pipe:
The wget part outputs the raw html code
html2txt formats the raw html into what the page looks like when viewed in links
grep returned " hh:mm:ss" (filled in with the time)
(when I tried grep -E '[[:digit:]]{2}:[[:digit:]]{2}:[[:digit:]]{2}' I got ""
and sed just got rid of the extra spaces
The error messages I got with my date commands are:
date: invalid date `2\b20\b0:\b:4\b47\b7:\b:4\b44\b4'
and with sh -x: /bin/date: /bin/date: cannot execute binary file
In the future I think I will use ntpdate, but I'm still interested in why date isn't accepting my input.
but the od -c give different results than your does when I enter wget -o /dev/null http://www.time.gov/timezone.cgi?Eastern/d/-5 -O - | html2text | grep ..\:.. | sed 's/ //g' | od -c (is this is expected?)
Thank you both for pointing out the weird output. I didn't have html2text installed so I couldn't see anything wrong with the grep I posted earlier. I installed it, got the control codes, etc. and breathed a sigh of relief...
For the control character in the sed filter "-e 's/^B.//', I typed it by pressing Cntrl-v Cntrl-b. It isn't the literal characters '^B'. Nevertheless, it's wrong all the same. It should be [Cntrl]-v[Cntrl-h.
And the substitution should be done globally on the line.
"-e 's/^H//g'"
It worked! I just added backquotes to the '^H' (typed as ctrl+v, ctrl+h)version of the script and it corrected the clock. I guess I need to brush up on my control and escape characters
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.