How to use password retrieved from `pass` in a shell scriptTrying to cp a path with spaces, fails when...

What happens when a metallic dragon and a chromatic dragon mate?

Creating a loop after a break using Markov Chain in Tikz

Need help identifying/translating a plaque in Tangier, Morocco

Does the average primeness of natural numbers tend to zero?

Doomsday-clock for my fantasy planet

Why do UK politicians seemingly ignore opinion polls on Brexit?

Pristine Bit Checking

Can I legally use front facing blue light in the UK?

Can the Produce Flame cantrip be used to grapple, or as an unarmed strike, in the right circumstances?

Why did the Germans forbid the possession of pet pigeons in Rostov-on-Don in 1941?

Unbreakable Formation vs. Cry of the Carnarium

COUNT(*) or MAX(id) - which is faster?

Ideas for 3rd eye abilities

Where else does the Shulchan Aruch quote an authority by name?

Information to fellow intern about hiring?

Why is my log file so massive? 22gb. I am running log backups

Re-submission of rejected manuscript without informing co-authors

Is this food a bread or a loaf?

Can I find out the caloric content of bread by dehydrating it?

Is Social Media Science Fiction?

Is this relativistic mass?

Prime joint compound before latex paint?

Why airport relocation isn't done gradually?

Extreme, but not acceptable situation and I can't start the work tomorrow morning



How to use password retrieved from `pass` in a shell script


Trying to cp a path with spaces, fails when scripted but echoing and pasting succeeds?SSH Tunneling Through a Firewall to a ClusterHow to use password in shell scriptingBash variable containing JSON splits on single quotesHow to pass array to bash shell script?variable not being read correctlyRetrieved value from associative array is wrong?bash subshell export variablePass A File Through Shell ScriptBash Script - How can I concatenate several strings containing special characters?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







0















I stored a password in using the pass and based I am trying to automate a VPN Connection process using Cisco Anyconnect. The VPN works, I confirmed that. The script I am trying to use is:



pass=$(pass branch/key)
vpn -s connect vpn.server.host << "EOF"
0
username
"$pass"
y
exit
EOF


Suppose I save that as .connectvpn and say source .connectvpn then it should start a VPN tunnel and get a connection going.



If in the file I get rid of the variable I am trying to use (pass), and put the actual password on the fifth line I know it works. The trouble I am having is with the bash variable approach.










share|improve this question







New contributor




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



























    0















    I stored a password in using the pass and based I am trying to automate a VPN Connection process using Cisco Anyconnect. The VPN works, I confirmed that. The script I am trying to use is:



    pass=$(pass branch/key)
    vpn -s connect vpn.server.host << "EOF"
    0
    username
    "$pass"
    y
    exit
    EOF


    Suppose I save that as .connectvpn and say source .connectvpn then it should start a VPN tunnel and get a connection going.



    If in the file I get rid of the variable I am trying to use (pass), and put the actual password on the fifth line I know it works. The trouble I am having is with the bash variable approach.










    share|improve this question







    New contributor




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























      0












      0








      0








      I stored a password in using the pass and based I am trying to automate a VPN Connection process using Cisco Anyconnect. The VPN works, I confirmed that. The script I am trying to use is:



      pass=$(pass branch/key)
      vpn -s connect vpn.server.host << "EOF"
      0
      username
      "$pass"
      y
      exit
      EOF


      Suppose I save that as .connectvpn and say source .connectvpn then it should start a VPN tunnel and get a connection going.



      If in the file I get rid of the variable I am trying to use (pass), and put the actual password on the fifth line I know it works. The trouble I am having is with the bash variable approach.










      share|improve this question







      New contributor




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












      I stored a password in using the pass and based I am trying to automate a VPN Connection process using Cisco Anyconnect. The VPN works, I confirmed that. The script I am trying to use is:



      pass=$(pass branch/key)
      vpn -s connect vpn.server.host << "EOF"
      0
      username
      "$pass"
      y
      exit
      EOF


      Suppose I save that as .connectvpn and say source .connectvpn then it should start a VPN tunnel and get a connection going.



      If in the file I get rid of the variable I am trying to use (pass), and put the actual password on the fifth line I know it works. The trouble I am having is with the bash variable approach.







      bash terminal






      share|improve this question







      New contributor




      ITA 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




      ITA 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






      New contributor




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









      asked yesterday









      ITAITA

      1032




      1032




      New contributor




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





      New contributor





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






      ITA 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


















          2














          Your problem is that you have quoted the delimiter, "EOF". When the delimiter of a here-document is quoted, no parameter expansion is performed on the body, so your password gets its literal value, "$pass". Try using EOF without quotes as a delimiter.






          share|improve this answer
























            Your Answer








            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "106"
            };
            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: false,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            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
            });


            }
            });






            ITA 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%2funix.stackexchange.com%2fquestions%2f511125%2fhow-to-use-password-retrieved-from-pass-in-a-shell-script%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









            2














            Your problem is that you have quoted the delimiter, "EOF". When the delimiter of a here-document is quoted, no parameter expansion is performed on the body, so your password gets its literal value, "$pass". Try using EOF without quotes as a delimiter.






            share|improve this answer




























              2














              Your problem is that you have quoted the delimiter, "EOF". When the delimiter of a here-document is quoted, no parameter expansion is performed on the body, so your password gets its literal value, "$pass". Try using EOF without quotes as a delimiter.






              share|improve this answer


























                2












                2








                2







                Your problem is that you have quoted the delimiter, "EOF". When the delimiter of a here-document is quoted, no parameter expansion is performed on the body, so your password gets its literal value, "$pass". Try using EOF without quotes as a delimiter.






                share|improve this answer













                Your problem is that you have quoted the delimiter, "EOF". When the delimiter of a here-document is quoted, no parameter expansion is performed on the body, so your password gets its literal value, "$pass". Try using EOF without quotes as a delimiter.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered yesterday









                Dmitry GrigoryevDmitry Grigoryev

                5,1241045




                5,1241045






















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










                    draft saved

                    draft discarded


















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













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












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
















                    Thanks for contributing an answer to Unix & Linux Stack Exchange!


                    • 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%2funix.stackexchange.com%2fquestions%2f511125%2fhow-to-use-password-retrieved-from-pass-in-a-shell-script%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

                    Taj Mahal Inhaltsverzeichnis Aufbau | Geschichte | 350-Jahr-Feier | Heutige Bedeutung | Siehe auch |...

                    Baia Sprie Cuprins Etimologie | Istorie | Demografie | Politică și administrație | Arii naturale...

                    Nicolae Petrescu-Găină Cuprins Biografie | Opera | In memoriam | Varia | Controverse, incertitudini...