I'm trying to parse a url to set my hardware & system clock (linux).
Perhaps the best way to do this would be to use the urllib2 module to
convert a site to text, but since I haven't found that option yet, I did
this instead (which sometimes works, sometimes doesn't, and when it doesn't
seems to get hung up on line 4 -- os.popen oddity?):
#/usr/bin/env python
import os,sys
url = "http://www.time.gov/timezone.cgi?Ce ntral/d/-6"
f = os.popen("lynx -dump " + url)
lines = f.readlines()
i = 0
for line in lines:
lines[i] = line.strip()
i += 1
for i in range(len(s)):
if s[i].find("Right now") > -1:
break
time = s[1]
day,month,year = s[2].split(',')
month = month.strip()
month = month.split(' ')
month = ' '.join([month[0][0:3],month[1]])
year = year.strip()
result = ' '.join([day, month, time, "CDT", year])
print "result is %s.\n" % result
command = 'date -u -s "' + result + '";hwclock --systohc'
print "Command is: \n\n%s.\n" % command
f = os.popen(comman d)
print f.read()
# updatetime.py
import: Unable to open file (os,sys).
/usr/local/bin/updatetime.py: line 4: url: command not found
/usr/local/bin/updatetime.py: line 5: syntax error near unexpected token `('
/usr/local/bin/updatetime.py: line 5: `f = os.popen("lynx -dump " + url)'
I'm fetching a site
--
Stephen
From here to there
and there to here,
funny things are everywhere. -- Dr Seuss 4 1706
Stephen Boulet wrote: I'm trying to parse a url to set my hardware & system clock (linux).
I can't help with the problem at hand, but I also don't see the
reason to do it. Why not just access an NTP server and grab the
time the "proper" way? Using a web page is a roundabout way of
doing it. There's a nice setclock.py script which Google can
point you to which does the job much more easily.
-Peter
Peter Hansen <pe***@engcorp. com> writes: Stephen Boulet wrote: I'm trying to parse a url to set my hardware & system clock (linux). I can't help with the problem at hand, but I also don't see the reason to do it. Why not just access an NTP server and grab the time the "proper" way? Using a web page is a roundabout way of doing it.
Right.
There's a nice setclock.py script which Google can point you to which does the job much more easily.
On my system, the ntpdate command works nicely. I run it my PPP
scripts.
John
You guys are probably right. If you have a hammer ...
John J. Lee wrote: Peter Hansen <pe***@engcorp. com> writes:
Stephen Boulet wrote:
I'm trying to parse a url to set my hardware & system clock (linux).
I can't help with the problem at hand, but I also don't see the reason to do it. Why not just access an NTP server and grab the time the "proper" way? Using a web page is a roundabout way of doing it.
Right.
There's a nice setclock.py script which Google can point you to which does the job much more easily.
On my system, the ntpdate command works nicely. I run it my PPP scripts.
John
"John J. Lee" wrote: Peter Hansen <pe***@engcorp. com> writes:
Stephen Boulet wrote: I'm trying to parse a url to set my hardware & system clock (linux).
I can't help with the problem at hand, but I also don't see the reason to do it. Why not just access an NTP server and grab the time the "proper" way? Using a web page is a roundabout way of doing it.
Right.
There's a nice setclock.py script which Google can point you to which does the job much more easily.
On my system, the ntpdate command works nicely. I run it my PPP scripts.
And once one knows it exists, one should probably prefer that
method. As I now do. <grin>
-Peter This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Andres Baravalle |
last post by:
Hi,
I have a problem using a URL fetching algorithm (HTTP 1.0).
To download an image, I used to use this algorithm:
<?php
Header("Content-type: image/gif");
$referer = "http://www.creators.com/comics_show.cfm?comicname=mrh";
|
by: Penn Markham |
last post by:
Hello all,
I am writing a script where I need to use the system() function to call
htpasswd. I can do this just fine on the command line...works great
(see attached file, test.php). When my webserver runs that part of the
script (see attached file, snippet.php), though, it doesn't go through.
I don't get an error message or anything...it just returns a "1"
(whereas it should return a "0") as far as I can tell. I have read the
PHP...
|
by: keith_h |
last post by:
I am primarily a front-end designer and not familiar with ASP beyond
breaking up pages into include files. Recently, one of my freelance
clients wanted to display an RSS feed from his blog on his site. I did
some research and found the rss2html.asp script. I chose this over a
javascript solution because those scripts apparently don't affect
search engine rankings.
I implemented the script and it was running fine until about a month
ago,...
|
by: eyal.susser |
last post by:
Hi,
I'm trying to write a script that uses diffxml along with 4xupdate
to merge XML files. So far, I'm having trouble with even the most
basic files. I have tried different versions of the components, to no
avail. Are there any alternatives? I've put sample files below.
Thanks,
Eyal.
|
by: Sandman |
last post by:
So, I have this content management system I've developed myself. The
system has a solid community part where members can register and then
participate in forums, write weblogs and a ton of other things.
So, in instances where I list, for example, the latest weblogs. I list
the headline of the weblog, the date and the name of the member who
wrote it.
Now, the name isn't just "Smith", but rather Smith's online status,
his nick and his...
| |
by: 8anos |
last post by:
Hello,
I am new at the community and newbie at programming :)
As you may know rapidshare provides a perl script for linux, to upload files at their servers.
You can find the original scripts at rapidshare news :
http://images.rapidshare.com/software/rsapi.pl
If you test it you will see that you can upload one file at time.
I try to modify it in that way that script can read a text file with the names of the files i want to...
|
by: Gilles Ganault |
last post by:
Hello
I need to write a script to automate fetching data from a web site:
1. using the POST method, log on, with login/password saved as cookies
2. download page and extract relevent information using regexes
3. log off
4. wait for a random number of minutes, and GOTO 1
I'm a bit confused with how to get POST and cookies in the same
script:
|
by: matheussousuke |
last post by:
Hi guys, good morning.
I've just get this script for converting mysql tables from wordpress, and I want to use it in my server, but no with wordpress, with oscommerce, a friend of mine told me a few things I should do for make it working, but less than a rookie in PHP, began studying it now ¬¬", and sure I dont know how to use command line yet, she told me something about using command line along with FTP ascii table, I'm lost, couldn't do...
|
by: matheussousuke |
last post by:
Hello, I'm using tiny MCE plugin on my oscommerce and it is inserting my website URL when I use insert image function in the emails.
The goal is: Make it send the email with the URL http://mghospedagem.com/images/controlpanel.jpg
instead of
http://mghospedagem.comhttp://mghospedagem.com/images/controlpanel.jpg
As u see, there's the website URL before the image URL.
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |