By default, Lynx will not save the cookies of the session, even when requesting it from the command line. To get around that, create a configuration file and add the following:
SET_COOKIES:TRUE ACCEPT_ALL_COOKIES:TRUE PERSISTENT_COOKIES:TRUE COOKIE_FILE:cookies.txt
To record a script use
lynx -cmd_log=SCRIPT_FILE http://www.example.com
To execute te script use
lynx -cmd_script=SCRIPT_FILE http://www.example.com
About terminal type
I ran into an issue when running lynx as part of a cron task. The script file was created using a different display size than what lynx assumed it to be at runtime. I had to record the screen in a terminal window set at 80x24 and then adding the following to the configuration file:
TERM:VT100 LINES:24 COLUMNS:80
Lynx : self sign SSL
Lynx will ask for confirmation on Self-Signed ssl certificates. This may be a problem when trying to script the app. To avoid the confirmation prompts I did the following:
- Edit the file /etc/lynx-cur/lynx.cfg
- Add/Replace this entry: ENABLE_LYNXRC:force_ssl_prompt:ON
- Load lynx and hit 'o' to enter the options screen.
- Locate Security and Privacy and change the Setting "SSL Prompting" to "force yes-response"
- Remember to save the settings to DISK! This will create a file in the root of the user folder named .lynxrc
This is the command I'm using to execute lynx in Dreamhost.
#!/bin/bash /usr/bin/lynx -cfg=/home/makkos/com.splat-n/media/fitbit/lynx/lynx.cfg -cmd_script=/home/makkos/com.splat-n/media/fitbit/lynx/lynx.scp -accept_all_cookies -term=VT100 https://www.fitbit.com/login
Complete Configuration File
SET_COOKIES:TRUE ACCEPT_ALL_COOKIES:TRUE PERSISTENT_COOKIES:TRUE COOKIE_FILE:/home/makkos/com.splat-n/media/fitbit/cookiejar/fitbitCookie ENABLE_LYNXRC:force_ssl_prompt:ON TERM:VT100 LINES:24 COLUMNS:80