Advertisement
Jakeukalane

open urls

Jan 7th, 2023
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. Sure, here is a modified version of the previous script that uses nohup to run the script in the background and allows the user to stop the script by pressing any key:
  2.  
  3. Copy code
  4. #!/bin/bash
  5.  
  6. # Set path to file with URLs
  7. file="path/to/urls.txt"
  8.  
  9. # Set interval (in seconds)
  10. interval=300
  11.  
  12. while true; do
  13. # Read next URL from file
  14. url=$(head -n 1 "$file")
  15.  
  16. # Open URL in new tab
  17. chromium-browser --new-tab "$url"
  18.  
  19. # Remove URL from file
  20. sed -i 1d "$file"
  21.  
  22. # Add URL to end of file
  23. echo "$url" >> "$file"
  24.  
  25. # Sleep for specified interval
  26. sleep "$interval"
  27.  
  28. # Check if user pressed a key
  29. if read -t 0; then
  30. break
  31. fi
  32. done
  33. To use this script, save it to a file and make it executable with chmod +x <filename>. Then, create a text file with the list of URLs you want to open, one per line, and specify the path to the file in the file variable. Finally, run the script with nohup ./<filename> &, which will run the script in the background and allow you to close the terminal without stopping the script.
  34.  
  35. To stop the script, you can use the fg command to bring it to the foreground and then press any key to stop the script. For example:
  36.  
  37. Copy code
  38. fg
  39. <press any key>
  40. I hope this helps
  41.  
  42.  
  43.  
  44.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement