View previous topic :: View next topic |
Author |
Message |
handsomepete Guru
Joined: 21 Apr 2002 Posts: 548 Location: Kansas City, MO
|
Posted: Sat Jun 29, 2002 6:54 pm Post subject: Shell Scripting + Lynx |
|
|
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 |
|
|
pjp Administrator
Joined: 16 Apr 2002 Posts: 20054
|
Posted: Sat Jun 29, 2002 7:11 pm Post subject: |
|
|
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 |
|
|
handsomepete Guru
Joined: 21 Apr 2002 Posts: 548 Location: Kansas City, MO
|
Posted: Sat Jun 29, 2002 7:26 pm Post subject: |
|
|
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 |
|
|
pjp Administrator
Joined: 16 Apr 2002 Posts: 20054
|
Posted: Sat Jun 29, 2002 7:54 pm Post subject: |
|
|
Out of curiosity, what are you doing to come up with the double digits etc.? _________________ Quis separabit? Quo animo? |
|
Back to top |
|
|
handsomepete Guru
Joined: 21 Apr 2002 Posts: 548 Location: Kansas City, MO
|
Posted: Sat Jun 29, 2002 8:39 pm Post subject: |
|
|
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 |
|
|
|
|
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
|
|