Help - Search - Members - Calendar
Full Version: Passing Key Commands Via Bash?
Linuxhelp > Support > Programming in Linux
Jim
I don't know if this is possible, but hey, its worth asking.

I am trying to automate a process using bash so I can cron it right. I am using lynx to log into an authentication server and using the -cmd_script= option provide by lynx. Trouble is, I need to wait 120 seconds, then reload in order for the log in to work, and lynx's script has no way (that i know of) to suppor this, so is there any way I can do this via bash?

Thanks.
michaelk
Use the sleep command.
http://linux.about.com/library/cmd/blcmdl1_sleep.htm
Jim
Ya the sleep command gets me the pause, but how do I get the key command to lynx? The lynx script is seperate from the bash script and it just contains the key commands I want to run. Basically I need this. I need lynx to start up, go through its script file, then about 120 seconds later I need to pass it "ctrl+R" so it will reload and finish. The sleep command will get me the pause, but how do I get the command passed to lynx?

Pluse if I haves a script like

lynx --cmd_script=scriptfile
sleep
'pass keys'

It wont go to sleep until lynx is finished, which it can't do, till I pass it the reload... you see the problem?
michaelk
I believe you can execute local commands from the scriptfile. So in theory you could sleep and then reload.
Jim
Even if I could set that up, I don't know how to pass "ctrl+R" to an already running copy of lynx.
michaelk
A search didn't return any useful information on special key other then down arrow from the documentation. From what I gathered you can log a session and it will save keystrokes. Just guessing this log will contain key strokes and all you need to do is copy them to your file.
Jim
I already have the key log for lynx, that isn't the problem. The problem is that they key entry for ctrl+R thats in the log runs as soon as it can, I need it to wait 120 seconds. Its this stupid script. What ever, I appreciate the help, but I don't think it can be done.
DS2K3
You want to pipe stuff to the stdin of lynx? If you have the PHP CLI installed, then you could use the process andling functions to do it. I daresay Perl/Python etc. could do it too.

D
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2017 Invision Power Services, Inc.