Script to open a website using a terminal automatically, remembering cookies












1















Is there any way to make a script, which opens the URL with a minute interval, automatically, remembering old cookies?



It must be run from ssh, not always connected.










share|improve this question









New contributor




dellek is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

























    1















    Is there any way to make a script, which opens the URL with a minute interval, automatically, remembering old cookies?



    It must be run from ssh, not always connected.










    share|improve this question









    New contributor




    dellek is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.























      1












      1








      1








      Is there any way to make a script, which opens the URL with a minute interval, automatically, remembering old cookies?



      It must be run from ssh, not always connected.










      share|improve this question









      New contributor




      dellek is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.












      Is there any way to make a script, which opens the URL with a minute interval, automatically, remembering old cookies?



      It must be run from ssh, not always connected.







      command-line scripts browser






      share|improve this question









      New contributor




      dellek is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      share|improve this question









      New contributor




      dellek is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      share|improve this question




      share|improve this question








      edited 13 hours ago









      LeonidMew

      647518




      647518






      New contributor




      dellek is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked Feb 27 at 21:31









      dellekdellek

      61




      61




      New contributor




      dellek is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      dellek is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      dellek is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






















          1 Answer
          1






          active

          oldest

          votes


















          -1














          New answer:



          I make text only version of script what you may run in background easily, with help of screen or cron.




          Screen is better option for long running processes. Using screen you
          can simply get the same session running on remote server even after
          logout from ssh.




          First start screen: $ screen



          Run elinks 'Yoursite'. Manage login or anything else you want to affect cookies. Exit. Run my script in screen.




          Let’s detach your screen session with keyboard shortcut CTRL+a+d or
          ctrl+alt+d. It will return you to command line. Now exit your ssh
          session and again connect system through ssh and execute following
          command to get old screen session running.



          $ screen -r




          Script follows, I have test it on web mail to test cookies, all work fine, loggeg in once and stay logged in restarts of script.



          #!/bin/bash

          while :
          do
          elinks 'yandex.ru' &
          sleep 50s
          pkill -u "$(id -un)" elinks
          echo "elinks killed, press ctrl-C to cancel loop. sleep 10s."
          sleep 10s
          done


          Note: elinks version from repo doesn't support javascript. Current version, if you build your self will support javascript if dependencies met.






          Old answer, for history purposes:

          First install xpra, its like screen but for X. sudo apt install xpra. Script will connect to xpra as ssh connected to X Display and script runs.



          On remote server run following:



          [remote] $ xpra start :13


          On local server run following: (each time after disconnect)



          [local] $ xpra attach ssh:remote:13


          Now run script on remote server following way:



          [remote] $ DISPLAY=:13 /bin/bash firefox-reload.sh


          firefox-reload.sh is following:



          #!/bin/bash

          for OUTPUT in $(firefox 'ya.ru' &)
          do
          pid = $!
          sleep 30s
          kill "$pid"
          sleep 30s
          done


          Update: I have tested text only browsers links and lynx. First not remember cookies between sessions, second - I was unable to test it fully cause it doesn't allow to submit form may be because of javascript.(web mail was used to test, if I stay logged in on second browser run)






          share|improve this answer


























          • Error: no DISPLAY environment variable specified, and i don't know how to use cookie with that

            – dellek
            2 days ago













          • It should be run under X, then DISPLAY will be available, and cookie handled automatically by firefox

            – LeonidMew
            2 days ago











          • Great, but this idea must work even when I close the SSH connection

            – dellek
            yesterday













          • I will improve script. Do you able to get desktop(forwarding x for ssh) or other way? What else needed. May be killing old firefox on 50 seconds of 1 minute? It also possible to use text browsers but I don't known how they handle cookies between sessions, and don't support many modern browser features.

            – LeonidMew
            yesterday











          • of course, I'm able.

            – dellek
            yesterday











          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "89"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });






          dellek is a new contributor. Be nice, and check out our Code of Conduct.










          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1121809%2fscript-to-open-a-website-using-a-terminal-automatically-remembering-cookies%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          -1














          New answer:



          I make text only version of script what you may run in background easily, with help of screen or cron.




          Screen is better option for long running processes. Using screen you
          can simply get the same session running on remote server even after
          logout from ssh.




          First start screen: $ screen



          Run elinks 'Yoursite'. Manage login or anything else you want to affect cookies. Exit. Run my script in screen.




          Let’s detach your screen session with keyboard shortcut CTRL+a+d or
          ctrl+alt+d. It will return you to command line. Now exit your ssh
          session and again connect system through ssh and execute following
          command to get old screen session running.



          $ screen -r




          Script follows, I have test it on web mail to test cookies, all work fine, loggeg in once and stay logged in restarts of script.



          #!/bin/bash

          while :
          do
          elinks 'yandex.ru' &
          sleep 50s
          pkill -u "$(id -un)" elinks
          echo "elinks killed, press ctrl-C to cancel loop. sleep 10s."
          sleep 10s
          done


          Note: elinks version from repo doesn't support javascript. Current version, if you build your self will support javascript if dependencies met.






          Old answer, for history purposes:

          First install xpra, its like screen but for X. sudo apt install xpra. Script will connect to xpra as ssh connected to X Display and script runs.



          On remote server run following:



          [remote] $ xpra start :13


          On local server run following: (each time after disconnect)



          [local] $ xpra attach ssh:remote:13


          Now run script on remote server following way:



          [remote] $ DISPLAY=:13 /bin/bash firefox-reload.sh


          firefox-reload.sh is following:



          #!/bin/bash

          for OUTPUT in $(firefox 'ya.ru' &)
          do
          pid = $!
          sleep 30s
          kill "$pid"
          sleep 30s
          done


          Update: I have tested text only browsers links and lynx. First not remember cookies between sessions, second - I was unable to test it fully cause it doesn't allow to submit form may be because of javascript.(web mail was used to test, if I stay logged in on second browser run)






          share|improve this answer


























          • Error: no DISPLAY environment variable specified, and i don't know how to use cookie with that

            – dellek
            2 days ago













          • It should be run under X, then DISPLAY will be available, and cookie handled automatically by firefox

            – LeonidMew
            2 days ago











          • Great, but this idea must work even when I close the SSH connection

            – dellek
            yesterday













          • I will improve script. Do you able to get desktop(forwarding x for ssh) or other way? What else needed. May be killing old firefox on 50 seconds of 1 minute? It also possible to use text browsers but I don't known how they handle cookies between sessions, and don't support many modern browser features.

            – LeonidMew
            yesterday











          • of course, I'm able.

            – dellek
            yesterday
















          -1














          New answer:



          I make text only version of script what you may run in background easily, with help of screen or cron.




          Screen is better option for long running processes. Using screen you
          can simply get the same session running on remote server even after
          logout from ssh.




          First start screen: $ screen



          Run elinks 'Yoursite'. Manage login or anything else you want to affect cookies. Exit. Run my script in screen.




          Let’s detach your screen session with keyboard shortcut CTRL+a+d or
          ctrl+alt+d. It will return you to command line. Now exit your ssh
          session and again connect system through ssh and execute following
          command to get old screen session running.



          $ screen -r




          Script follows, I have test it on web mail to test cookies, all work fine, loggeg in once and stay logged in restarts of script.



          #!/bin/bash

          while :
          do
          elinks 'yandex.ru' &
          sleep 50s
          pkill -u "$(id -un)" elinks
          echo "elinks killed, press ctrl-C to cancel loop. sleep 10s."
          sleep 10s
          done


          Note: elinks version from repo doesn't support javascript. Current version, if you build your self will support javascript if dependencies met.






          Old answer, for history purposes:

          First install xpra, its like screen but for X. sudo apt install xpra. Script will connect to xpra as ssh connected to X Display and script runs.



          On remote server run following:



          [remote] $ xpra start :13


          On local server run following: (each time after disconnect)



          [local] $ xpra attach ssh:remote:13


          Now run script on remote server following way:



          [remote] $ DISPLAY=:13 /bin/bash firefox-reload.sh


          firefox-reload.sh is following:



          #!/bin/bash

          for OUTPUT in $(firefox 'ya.ru' &)
          do
          pid = $!
          sleep 30s
          kill "$pid"
          sleep 30s
          done


          Update: I have tested text only browsers links and lynx. First not remember cookies between sessions, second - I was unable to test it fully cause it doesn't allow to submit form may be because of javascript.(web mail was used to test, if I stay logged in on second browser run)






          share|improve this answer


























          • Error: no DISPLAY environment variable specified, and i don't know how to use cookie with that

            – dellek
            2 days ago













          • It should be run under X, then DISPLAY will be available, and cookie handled automatically by firefox

            – LeonidMew
            2 days ago











          • Great, but this idea must work even when I close the SSH connection

            – dellek
            yesterday













          • I will improve script. Do you able to get desktop(forwarding x for ssh) or other way? What else needed. May be killing old firefox on 50 seconds of 1 minute? It also possible to use text browsers but I don't known how they handle cookies between sessions, and don't support many modern browser features.

            – LeonidMew
            yesterday











          • of course, I'm able.

            – dellek
            yesterday














          -1












          -1








          -1







          New answer:



          I make text only version of script what you may run in background easily, with help of screen or cron.




          Screen is better option for long running processes. Using screen you
          can simply get the same session running on remote server even after
          logout from ssh.




          First start screen: $ screen



          Run elinks 'Yoursite'. Manage login or anything else you want to affect cookies. Exit. Run my script in screen.




          Let’s detach your screen session with keyboard shortcut CTRL+a+d or
          ctrl+alt+d. It will return you to command line. Now exit your ssh
          session and again connect system through ssh and execute following
          command to get old screen session running.



          $ screen -r




          Script follows, I have test it on web mail to test cookies, all work fine, loggeg in once and stay logged in restarts of script.



          #!/bin/bash

          while :
          do
          elinks 'yandex.ru' &
          sleep 50s
          pkill -u "$(id -un)" elinks
          echo "elinks killed, press ctrl-C to cancel loop. sleep 10s."
          sleep 10s
          done


          Note: elinks version from repo doesn't support javascript. Current version, if you build your self will support javascript if dependencies met.






          Old answer, for history purposes:

          First install xpra, its like screen but for X. sudo apt install xpra. Script will connect to xpra as ssh connected to X Display and script runs.



          On remote server run following:



          [remote] $ xpra start :13


          On local server run following: (each time after disconnect)



          [local] $ xpra attach ssh:remote:13


          Now run script on remote server following way:



          [remote] $ DISPLAY=:13 /bin/bash firefox-reload.sh


          firefox-reload.sh is following:



          #!/bin/bash

          for OUTPUT in $(firefox 'ya.ru' &)
          do
          pid = $!
          sleep 30s
          kill "$pid"
          sleep 30s
          done


          Update: I have tested text only browsers links and lynx. First not remember cookies between sessions, second - I was unable to test it fully cause it doesn't allow to submit form may be because of javascript.(web mail was used to test, if I stay logged in on second browser run)






          share|improve this answer















          New answer:



          I make text only version of script what you may run in background easily, with help of screen or cron.




          Screen is better option for long running processes. Using screen you
          can simply get the same session running on remote server even after
          logout from ssh.




          First start screen: $ screen



          Run elinks 'Yoursite'. Manage login or anything else you want to affect cookies. Exit. Run my script in screen.




          Let’s detach your screen session with keyboard shortcut CTRL+a+d or
          ctrl+alt+d. It will return you to command line. Now exit your ssh
          session and again connect system through ssh and execute following
          command to get old screen session running.



          $ screen -r




          Script follows, I have test it on web mail to test cookies, all work fine, loggeg in once and stay logged in restarts of script.



          #!/bin/bash

          while :
          do
          elinks 'yandex.ru' &
          sleep 50s
          pkill -u "$(id -un)" elinks
          echo "elinks killed, press ctrl-C to cancel loop. sleep 10s."
          sleep 10s
          done


          Note: elinks version from repo doesn't support javascript. Current version, if you build your self will support javascript if dependencies met.






          Old answer, for history purposes:

          First install xpra, its like screen but for X. sudo apt install xpra. Script will connect to xpra as ssh connected to X Display and script runs.



          On remote server run following:



          [remote] $ xpra start :13


          On local server run following: (each time after disconnect)



          [local] $ xpra attach ssh:remote:13


          Now run script on remote server following way:



          [remote] $ DISPLAY=:13 /bin/bash firefox-reload.sh


          firefox-reload.sh is following:



          #!/bin/bash

          for OUTPUT in $(firefox 'ya.ru' &)
          do
          pid = $!
          sleep 30s
          kill "$pid"
          sleep 30s
          done


          Update: I have tested text only browsers links and lynx. First not remember cookies between sessions, second - I was unable to test it fully cause it doesn't allow to submit form may be because of javascript.(web mail was used to test, if I stay logged in on second browser run)







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited 14 hours ago

























          answered Feb 27 at 21:55









          LeonidMewLeonidMew

          647518




          647518













          • Error: no DISPLAY environment variable specified, and i don't know how to use cookie with that

            – dellek
            2 days ago













          • It should be run under X, then DISPLAY will be available, and cookie handled automatically by firefox

            – LeonidMew
            2 days ago











          • Great, but this idea must work even when I close the SSH connection

            – dellek
            yesterday













          • I will improve script. Do you able to get desktop(forwarding x for ssh) or other way? What else needed. May be killing old firefox on 50 seconds of 1 minute? It also possible to use text browsers but I don't known how they handle cookies between sessions, and don't support many modern browser features.

            – LeonidMew
            yesterday











          • of course, I'm able.

            – dellek
            yesterday



















          • Error: no DISPLAY environment variable specified, and i don't know how to use cookie with that

            – dellek
            2 days ago













          • It should be run under X, then DISPLAY will be available, and cookie handled automatically by firefox

            – LeonidMew
            2 days ago











          • Great, but this idea must work even when I close the SSH connection

            – dellek
            yesterday













          • I will improve script. Do you able to get desktop(forwarding x for ssh) or other way? What else needed. May be killing old firefox on 50 seconds of 1 minute? It also possible to use text browsers but I don't known how they handle cookies between sessions, and don't support many modern browser features.

            – LeonidMew
            yesterday











          • of course, I'm able.

            – dellek
            yesterday

















          Error: no DISPLAY environment variable specified, and i don't know how to use cookie with that

          – dellek
          2 days ago







          Error: no DISPLAY environment variable specified, and i don't know how to use cookie with that

          – dellek
          2 days ago















          It should be run under X, then DISPLAY will be available, and cookie handled automatically by firefox

          – LeonidMew
          2 days ago





          It should be run under X, then DISPLAY will be available, and cookie handled automatically by firefox

          – LeonidMew
          2 days ago













          Great, but this idea must work even when I close the SSH connection

          – dellek
          yesterday







          Great, but this idea must work even when I close the SSH connection

          – dellek
          yesterday















          I will improve script. Do you able to get desktop(forwarding x for ssh) or other way? What else needed. May be killing old firefox on 50 seconds of 1 minute? It also possible to use text browsers but I don't known how they handle cookies between sessions, and don't support many modern browser features.

          – LeonidMew
          yesterday





          I will improve script. Do you able to get desktop(forwarding x for ssh) or other way? What else needed. May be killing old firefox on 50 seconds of 1 minute? It also possible to use text browsers but I don't known how they handle cookies between sessions, and don't support many modern browser features.

          – LeonidMew
          yesterday













          of course, I'm able.

          – dellek
          yesterday





          of course, I'm able.

          – dellek
          yesterday










          dellek is a new contributor. Be nice, and check out our Code of Conduct.










          draft saved

          draft discarded


















          dellek is a new contributor. Be nice, and check out our Code of Conduct.













          dellek is a new contributor. Be nice, and check out our Code of Conduct.












          dellek is a new contributor. Be nice, and check out our Code of Conduct.
















          Thanks for contributing an answer to Ask Ubuntu!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1121809%2fscript-to-open-a-website-using-a-terminal-automatically-remembering-cookies%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          數位音樂下載

          When can things happen in Etherscan, such as the picture below?

          格利澤436b