Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Shell Scripting + Lynx
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
handsomepete
Guru
Guru


Joined: 21 Apr 2002
Posts: 548
Location: Kansas City, MO

PostPosted: Sat Jun 29, 2002 6:54 pm    Post subject: Shell Scripting + Lynx Reply with quote

I'm trying to write a little script to automagically hit an internal webpage, input the current date on a line and hit the submit button, then save the following page to an html file (dump to a text file and e-mail blah blah blah). I've got it all working except for one part - the date. Lynx scripting looks like this:

Code:

key 2
key 8
key -
key j
key u
key n
key -
key 2
key 0
key 0
key 2
key <space>
key 0
key 0
key :
key 0
key 0
key ^J


And that would be like typing in 28-jun-2002 00:00 (scripting through webpages is neat). The problem is parsing the date. I haven't been able to figure out a simple way to convert 28-jun-2002 00:00 to the above. Any standard command line utils that can output one char out of a string at a time? Am I forgetting something simple?
Back to top
View user's profile Send private message
pjp
Administrator
Administrator


Joined: 16 Apr 2002
Posts: 20054

PostPosted: Sat Jun 29, 2002 7:11 pm    Post subject: Reply with quote

I would guess sed or awk could do what your wanting. As I don't really know either,
you could try 'date +%H' (which returns just the 2 digit hour). Of course, repeating to
get all data you want.

Hopefully someone will read this and give you a real solution ;)
_________________
Quis separabit? Quo animo?
Back to top
View user's profile Send private message
handsomepete
Guru
Guru


Joined: 21 Apr 2002
Posts: 548
Location: Kansas City, MO

PostPosted: Sat Jun 29, 2002 7:26 pm    Post subject: Reply with quote

The problem is getting down to one digit at a time... i.e. I have no problem getting:
Code:

key 28
key -
key Jun
key -
key 2002
key 18
key :
key 32
key :


It's splitting up those solid numbers/letters into single characters that's getting me.
Back to top
View user's profile Send private message
pjp
Administrator
Administrator


Joined: 16 Apr 2002
Posts: 20054

PostPosted: Sat Jun 29, 2002 7:54 pm    Post subject: Reply with quote

Out of curiosity, what are you doing to come up with the double digits etc.?
_________________
Quis separabit? Quo animo?
Back to top
View user's profile Send private message
handsomepete
Guru
Guru


Joined: 21 Apr 2002
Posts: 548
Location: Kansas City, MO

PostPosted: Sat Jun 29, 2002 8:39 pm    Post subject: Reply with quote

I'm screwing around with the output of date -R. I just figured it out. Here's the code for those who are interested:
Code:

date -R | awk -F' ' '{print $2 "-" $3 "-" $4 $5}' | awk -F: '{print $1 ":" $2}' | awk '{print \
"key " substr($1, 1, 1) "\n" \
"key " substr($1, 2, 1) "\n" \
"key " substr($1, 3, 1) "\n" \
"key " substr($1, 4, 1) "\n" \
"key " substr($1, 5, 1) "\n" \
"key " substr($1, 6, 1) "\n" \
"key " substr($1, 7, 1) "\n" \
"key " substr($1, 8, 1) "\n" \
"key " substr($1, 9, 1) "\n" \
"key " substr($1, 10, 1) "\n" \
"key " substr($1, 11, 1) "\n" \
"key <space>" "\n" \
"key " substr($1, 12, 1) "\n" \
"key " substr($1, 13, 1) "\n" \
"key " substr($1, 14, 1) "\n" \
"key " substr($1, 15, 1) "\n" \
"key " substr($1, 16, 1) >> lynx_script


The 'substr' command basically just tells awk to print from a certain location in a string for a certain number of characters. It's an ugly little hack, but it works. Yay!
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum