1

I have a bash script that executes a web-based php script using lynx, then the browser stays active allowing the user to input commands. I would like to automate quitting lynx and continuing with the rest of the script.

In the script I have:

lynx "https://www.domain.com/script.php?"
[rest of script]

Is there a way to output a q followed by a y so the script will continue without needing input from the keyboard?

Zanna
  • 72,312
Don
  • 229
  • 1
  • 3
  • 16

1 Answers1

1

Use the -dump argument.

Example of lynx in a script:

#!/bin/bash

buffer=$(lynx -dump "https://www.domain.com/script.php?")

copyright=$(echo "$buffer"|egrep Copyright)
phonenumber=$(echo "$buffer"|egrep "]Call.*Chat"|awk '{print $5}')

echo -e "This domain has this Copyright notice:\n$copyright"
echo "Phone contact is: $phonenumber"

Running the above tested script will give this output:

$ ./script.sh
This domain has this Copyright notice:
   © Copyright  2017 Domain.com. All rights reserved.
Phone contact is: 800-403-3568
L. D. James
  • 25,444