Bash script need help with writing
This is my first post and first script. Just finished my first Linux class and I'm trying to put it all into practice. Accepting all criticism and help, TIA!
I am writing a script that would 1) Open my web browser 2) Search a random word using bing search, selected randomly from the dictionary 3) Wait 5 - 10 seconds then search another random word, repeating roughly 20 - 30 times 4) Close the web browser 5) Repeat once a day So far this is the code I have Code:
#! /bin/bash Also when the web browser is already open it gives the error Code:
[7259:7294:0731/114659.197592:ERROR:browser_gpu_channel_host_factory.cc(103)] Failed to launch GPU process. Lastly, I cannot figure out how to make it close the browser when it has finished its task. The uuid is different each time it loads. Thanks for any help! |
Try changing: for i in ${a} to: for i in ${a[*]}
(a simpler test could use: echo $i vs xdg-open; maybe seq vs shuf) Do you have to use xdg-open? Or could you use wget? 'run daily' makes me think of cron (but who will SEE browser?) pkill <browser_name> maybe I don't see a way to make xdg-open re-use SAME browser-window. (oh, is this like: mid-day pop-up flash-cards, on your screen?) TMI:jawa: hints: let n++; if [ $n -gt 23 ] ; then break ; fi ;sleep 9 Welcome to LQ! GREAT A+ job on 1st post! Best wishes! Let us know... (post test-case with just echo vs xdg, and just 2-3 iterations!) Hopefully, some other LQ'er will address the xdg/gui issues:eek: (while you're tackling crontab with my echo_a_few test-version;)) p.s. You didn't web-search that error [?] :tisk: IF proven guilty, A+ -> A :D |
Quote:
For example: Code:
#!/bin/bash |
Im writing a script that will deploy automatically and do searches due to the fact that my browser gives me points per search. Id like to utilize the max daily amount of points.
For the life of me I still cannot make it loop a specific number of times. ive put together loops on their own and tried to implement the script into it and i continually get errors. Im gonna mess with a few more days and ill let everyone know how it turns out. Appreciate all the help. Sorry about accidentally posting twice, Im a noob |
Code:
a=( $(shuf -n 1 /usr/share/dict/american-english) ) |
I cant believe I missed that! Thanks Michaelk, much appreciated!
|
I have not played with browsers much so will leave that to someone else, but I would change your process to feed a while loop:
Code:
while read -r word The above script can then called in cron to launch once a day. |
So I was able to get the script to do exactly what I want, thanks to all of your help. I appreciate it.
Now the last step is to set the script to a crontab and let it do its business at the desired time. cron cannot open a web browser, ive tried wget as well as xdg-open. With some google searching I have found that some people suggest that you put the command directly into the cron tab to open the web browser. I have done that as well with no luck. The only thing I can think of now is to find another way to schedule a job once a day... any suggestions. TIA |
|
Try this
Code:
xx yy * * * export DISPlAY=:0.0 && /path/to/my_script |
That did it.
Code:
export DISPLAY=:0 && |
Quote:
https://stackoverflow.com/questions/...19183#18919183. However using cron to open a web-browser is not recommended |
All times are GMT -5. The time now is 06:14 PM. |