I am new to Python and trying to connect to a router using serial connection, which means there exists a step of typing in "username/password". Can anyone provide a example of serial connection with username/password being involved in?
Thanks so much!!
-
Have you looked at pyserial and its miniterm example?Patrick Maupin– Patrick Maupin2015年08月12日 01:39:04 +00:00Commented Aug 12, 2015 at 1:39
-
@PatrickMaupin Yup! I did some research about Pyserial can not find an example with username/password case ..Lily– Lily2015年08月12日 12:22:53 +00:00Commented Aug 12, 2015 at 12:22
-
You can give a username and password to miniterm, right?Patrick Maupin– Patrick Maupin2015年08月12日 12:31:25 +00:00Commented Aug 12, 2015 at 12:31
-
In other words, how is username/password different from any other programmed interaction?Patrick Maupin– Patrick Maupin2015年08月12日 12:32:59 +00:00Commented Aug 12, 2015 at 12:32
-
@PatrickMaupin Do you mind giving couple lines of code showing where to add username/password? It does not have to be exactly right but I am just trying to understand the basic idea and concepts. Thanks so much!Lily– Lily2015年08月12日 14:32:49 +00:00Commented Aug 12, 2015 at 14:32
1 Answer 1
You are asking about the ability to handle requests from the serial port (such as a username or password prompt), and then to respond to those requests appropriately, such as by sending the username or password.
This is a fairly common use-case, but is not handled directly by pyserial, which only handles dumb pipes for bytes in both directions.
One package which might be of use is pexpect. Here is a paper that describes using pexpect in conjunction with pyserial to control and test routers: