top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How to execute screen command in python?

+2 votes
480 views

I have to do the following operation in python script

  1. Open a port using screen command, (USB COMPORT)
  2. execute a command
  3. wait for the result (next line of command)
  4. Compare the result
  5. Close the port
posted Mar 25, 2015 by Chirag Gangdev

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

In general, in python, you can run system commands by running

   from os import system

and then

system('whatever_shell_command')

So in your case you would type:

from os import system
system('screen')
answer Mar 25, 2015 by Amit Kumar Pandey
Ok Fine..
Then how will i execute command on this screen?
how will i check the o/p of that command on that screen?
Similar Questions
+1 vote

I have a requirement where I need to kill one process on remote windows machine. Following command just works fine if i have to kill process on local machine

os.system('taskkill /f /im processName.exe')

However I am not able to figure out how to execute this command on remote windows machine. So is there any way I can execute command from windows machine on remote windows machine ?
Note: my local machine is also windows (machine from where i have to execute command)

0 votes

How can write a python script which will execute some perl scripts in a gui and shouldn't be post processed....?

0 votes

I can log into a web site with pexpect but what I want to do is pipe the opening window to a file. Logging into the site opens the site window but I can't get the window to a file.

I can't use screen capture I need to get pexpect to pipe it to a txt file.

0 votes

What is the proper way in which I can execute dynamic MySQL queries in Python? I want to do dynamic queries for both CREATE and INSERT statement.
Here is my attempted code:

sql="create table %s (%%s, %%s, %%s ... )" % (tablename,''.join(fields)+' '.join(types))
cur.execute(sql) 

where 'field' is the fieldnames stored in a list and 'types' are the fieldtypes stored in a list.

0 votes

I'm new to Django. Is there any tell how to add a limit filter in Django?

...