Basically I have a python script that i run against a web page and it outputs a phone number contact if it finds one.
What i'm trying to code is a bash script which can automate its use on a list of urls. Which saves the results to a file so i can see which urls produced a phone number contact and which urls didn't. I want this in the same txt file with each urls result on a different line so that i can deduce which urls produced which results. EG
$cat log.txt
HTTPError: 404
224 265 899
HTTPError: 404
847 718 9300, + 1, 662 538 6500
The problem is that when i run my bash script, the http errors print to screen and the phone numbers print to the log file. Meaning i cant deduce which urls produced which results.
So at the moment my bash script reads a URLS.txt file into an array. Then adds the script command to the beginning of each url in the array. Then using a for loop, executes each command..
I've tried to search for a way to add a string to each line of the log.txt everytime the python command is executed but have had no luck. If i could do this I wouldnt need the errors as i could deduce which urls didnt work because there would just be the string on each line that didnt produce a result.
So if i set the string to "none?" the log.txt would look like this
none?
none? 224 265 899
none?
none? 847 718 9300, + 1, 662 538 6500
This is the code i have after i have put the URLs into an array.
scr1="python3 extract.py "
scr1arr1=( "${array1[@]/#/$scr1}" )
for each1 in "${scr1arr1[@]}"
do
$each1 >> log.txt
done
So this is what happens on screen when i execute the script.
HTTPError: 404
HTTPError: 404
and the log.txt looks like this
224 265 8990,
847 718 9300, + 1, 662 538 6500
Am i doing this all wrong? / Approaching the problem the wrong way?? I've literally spent days trying to work this out, I'm loosing sleep over it! I am very new to coding, so sorry if this has been covered already. I've searched many forums far and wide and not been able to find a solution.