6

I'm trying to automate a login process that can only be done through a browser. I am using the lynx browser to script the actions required to do this. Lynx does this by dumping a user's keystrokes into a file and then it allows a flag: -cmd_script=scriptfile to load the script.

I invoke lynx:

lynx -accept_all_cookies -cmd_script="myscript.lynx" www.example.com

From my interactive terminal, the resulting script works perfectly for me.

I have cron run the task and it doesn't work. I checked /var/log/everything.log and I noticed that when the script ran, lynx asks:

Your Terminal type is unknown!
Enter a terminal type: [vt100]

To fix this, I used the flag -term=linux which stopped the issue, but the login process still did not seem to get past the first page (by looking at the log file).

I've tried as many suggestions as I could find. I copied the results from env (in the interactive terminal) and pasted them into the script to see if the environment would fix it, but alas it did not.

Another note: My login process involves a redirect (which doesn't redirect in the lynx browser so I just follow the link it gives)

0

1 Answer 1

1

Turns out it was a simple mistake. When I used the flag -cmd_script="myscript.lynx", I had placed myscript.lynx in the same directory as the script (which happened to be /root/bin). I figured out that lynx was never running the script, the reason being that apparently cron runs from the home directory of the user. Because I was using root's crontab, it was searching /root for myscript.lynx, not /root/bin like I had hoped.

The simple fix? -cmd_script="/root/bin/myscript.lynx"

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.