How to start screen session with commands?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
1
down vote

favorite












I'm connecting to a device via screen that requires that I enter some credentials (username and password). It's getting annoying to do that on every entry, so I'd like to alias a command to do that for me:



This alias in ~/.bash_aliases is insufficient:



alias devlogin="sudo screen /dev/ttyACM0 9600 && 'rmyusername' && rmypassword"






share|improve this question


























    up vote
    1
    down vote

    favorite












    I'm connecting to a device via screen that requires that I enter some credentials (username and password). It's getting annoying to do that on every entry, so I'd like to alias a command to do that for me:



    This alias in ~/.bash_aliases is insufficient:



    alias devlogin="sudo screen /dev/ttyACM0 9600 && 'rmyusername' && rmypassword"






    share|improve this question
























      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      I'm connecting to a device via screen that requires that I enter some credentials (username and password). It's getting annoying to do that on every entry, so I'd like to alias a command to do that for me:



      This alias in ~/.bash_aliases is insufficient:



      alias devlogin="sudo screen /dev/ttyACM0 9600 && 'rmyusername' && rmypassword"






      share|improve this question














      I'm connecting to a device via screen that requires that I enter some credentials (username and password). It's getting annoying to do that on every entry, so I'd like to alias a command to do that for me:



      This alias in ~/.bash_aliases is insufficient:



      alias devlogin="sudo screen /dev/ttyACM0 9600 && 'rmyusername' && rmypassword"








      share|improve this question













      share|improve this question




      share|improve this question








      edited Jan 31 at 19:06

























      asked Jan 31 at 18:44









      tarabyte

      92741429




      92741429




















          2 Answers
          2






          active

          oldest

          votes

















          up vote
          1
          down vote













          Does it have to be screen? Another option is to instead use expect or similar to open the device, issue whatever commands are necessary, and then turn things over to the user. This has the advantage of keeping the password out of the command line (where it is often visible across the system):



          #!/usr/bin/env expect

          # open up serial and configure
          set fh [open /dev/ttyACM0 RDWR NOCTTY NONBLOCK]
          fconfigure $fh -mode 9600,n,8,1

          # link above up with expect
          spawn -noecho -open $fh
          send -- "rmyuser"
          send -- "rHunter2"

          # over to the user now
          interact





          share|improve this answer



























            up vote
            0
            down vote













            Using stuff with the right syntax seems to work:



            alias evdlogin="sudo screen /dev/ttyACM0 9600 -X stuff $'rmyusernamermypassword'"


            Note that it's generally bad practice to hard-code a password in plain text, but since this is a development environment...



            http://aperiodic.net/screen/quick_reference






            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',
              convertImagesToLinks: false,
              noModals: false,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: null,
              bindNavPrevention: true,
              postfix: "",
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              );



              );








               

              draft saved


              draft discarded


















              StackExchange.ready(
              function ()
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f421040%2fhow-to-start-screen-session-with-commands%23new-answer', 'question_page');

              );

              Post as a guest






























              2 Answers
              2






              active

              oldest

              votes








              2 Answers
              2






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes








              up vote
              1
              down vote













              Does it have to be screen? Another option is to instead use expect or similar to open the device, issue whatever commands are necessary, and then turn things over to the user. This has the advantage of keeping the password out of the command line (where it is often visible across the system):



              #!/usr/bin/env expect

              # open up serial and configure
              set fh [open /dev/ttyACM0 RDWR NOCTTY NONBLOCK]
              fconfigure $fh -mode 9600,n,8,1

              # link above up with expect
              spawn -noecho -open $fh
              send -- "rmyuser"
              send -- "rHunter2"

              # over to the user now
              interact





              share|improve this answer
























                up vote
                1
                down vote













                Does it have to be screen? Another option is to instead use expect or similar to open the device, issue whatever commands are necessary, and then turn things over to the user. This has the advantage of keeping the password out of the command line (where it is often visible across the system):



                #!/usr/bin/env expect

                # open up serial and configure
                set fh [open /dev/ttyACM0 RDWR NOCTTY NONBLOCK]
                fconfigure $fh -mode 9600,n,8,1

                # link above up with expect
                spawn -noecho -open $fh
                send -- "rmyuser"
                send -- "rHunter2"

                # over to the user now
                interact





                share|improve this answer






















                  up vote
                  1
                  down vote










                  up vote
                  1
                  down vote









                  Does it have to be screen? Another option is to instead use expect or similar to open the device, issue whatever commands are necessary, and then turn things over to the user. This has the advantage of keeping the password out of the command line (where it is often visible across the system):



                  #!/usr/bin/env expect

                  # open up serial and configure
                  set fh [open /dev/ttyACM0 RDWR NOCTTY NONBLOCK]
                  fconfigure $fh -mode 9600,n,8,1

                  # link above up with expect
                  spawn -noecho -open $fh
                  send -- "rmyuser"
                  send -- "rHunter2"

                  # over to the user now
                  interact





                  share|improve this answer












                  Does it have to be screen? Another option is to instead use expect or similar to open the device, issue whatever commands are necessary, and then turn things over to the user. This has the advantage of keeping the password out of the command line (where it is often visible across the system):



                  #!/usr/bin/env expect

                  # open up serial and configure
                  set fh [open /dev/ttyACM0 RDWR NOCTTY NONBLOCK]
                  fconfigure $fh -mode 9600,n,8,1

                  # link above up with expect
                  spawn -noecho -open $fh
                  send -- "rmyuser"
                  send -- "rHunter2"

                  # over to the user now
                  interact






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Feb 1 at 14:51









                  thrig

                  22.3k12852




                  22.3k12852






















                      up vote
                      0
                      down vote













                      Using stuff with the right syntax seems to work:



                      alias evdlogin="sudo screen /dev/ttyACM0 9600 -X stuff $'rmyusernamermypassword'"


                      Note that it's generally bad practice to hard-code a password in plain text, but since this is a development environment...



                      http://aperiodic.net/screen/quick_reference






                      share|improve this answer


























                        up vote
                        0
                        down vote













                        Using stuff with the right syntax seems to work:



                        alias evdlogin="sudo screen /dev/ttyACM0 9600 -X stuff $'rmyusernamermypassword'"


                        Note that it's generally bad practice to hard-code a password in plain text, but since this is a development environment...



                        http://aperiodic.net/screen/quick_reference






                        share|improve this answer
























                          up vote
                          0
                          down vote










                          up vote
                          0
                          down vote









                          Using stuff with the right syntax seems to work:



                          alias evdlogin="sudo screen /dev/ttyACM0 9600 -X stuff $'rmyusernamermypassword'"


                          Note that it's generally bad practice to hard-code a password in plain text, but since this is a development environment...



                          http://aperiodic.net/screen/quick_reference






                          share|improve this answer














                          Using stuff with the right syntax seems to work:



                          alias evdlogin="sudo screen /dev/ttyACM0 9600 -X stuff $'rmyusernamermypassword'"


                          Note that it's generally bad practice to hard-code a password in plain text, but since this is a development environment...



                          http://aperiodic.net/screen/quick_reference







                          share|improve this answer














                          share|improve this answer



                          share|improve this answer








                          edited Feb 2 at 6:34

























                          answered Jan 31 at 19:05









                          tarabyte

                          92741429




                          92741429






















                               

                              draft saved


                              draft discarded


























                               


                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function ()
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f421040%2fhow-to-start-screen-session-with-commands%23new-answer', 'question_page');

                              );

                              Post as a guest













































































                              Popular posts from this blog

                              How to check contact read email or not when send email to Individual?

                              Displaying single band from multi-band raster using QGIS

                              How many registers does an x86_64 CPU actually have?