Hmm...
What in case when the first script (the one that uses raw_input) is not a python script, but simply some other script that i can only execute?
I am still trying :-)
Thanks for your comments and i am waiting for new ones :-)
Best regards,
User Profile
Collapse
Profile Sidebar
Collapse
Bierny
Last Activity: Mar 20 '08, 08:08 AM
Joined: Feb 23 '07
Location: Poland
-
popen2 issue
Hi All,
I am trying to do something new in python but at this moment i really don't know if it is possible.
I have a very simple python script that will simply prompt for any text and when the text it entered by a user the script will display it on a screen.
What i am trying to do is to start this simple script...Code:myInput = raw_input("Write something:") print myInput -
How to get a list of active processes under Unix
Hi All!
I am writting a small script that will find a parent pid and from this point find a parent of a parent in order to kill this last parent :-)
I know it sounds stange (at least ... ) but this is really what i have to do. So
When the script starts it find it's parent pid, like this
Afterwards a list of active processes is fetched from a console command ps...Code:ppid = os.getppid()
-
Hi,
Some time ago i wrote a script that downloads a zip archive and unpacks it. Here is a part of code that was taking care of extracting all files from the archive.
...Code:# open an archive file my_zipfile = zipfile.ZipFile(sampleZIPFilename,'r') # unzip all files from an archive for my_zippedfile in my_zipfile.namelist(): f = open(my_zippedfile,'w') f.write(my_zipfile.read(my_zippedfile))Leave a comment:
-
Hi,
Ok, I found it :-)
Let's say i want to send a message with following bytes "00201":
and later in order to unpack a received message:Code:import struct msg = struct.pack("!bbbbb", 0, 0, 2, 0, 1) mySocket.send(msg) ...
That should work ;-)Code:unpacked_msg = struct.unpack
Best...Leave a comment:
-
Socket - send message
Hi,
I would like to write a script which will connect to a server. I know I have to set up a tcp connection and after that send a registration message which consists of tag, length and value fields. All fields are bytes.
I have found a package "struct" which translates string to binary format but unfortunatelly I do not see appropriate format.
How can i do that?
Thanks in advance for any help/hints!... -
Ok, so this is the usual handling of a thread. The server thread should be a main thread so it has control over the client thread.
I can see a design mistake since I con not have to separete threads (meaning without main thread).
In that case I will rebuid the script so there is one main thread which controls the other one.
Thanks for your help!
Best regards,Leave a comment:
-
Now I am lost ... but maybe we could try different approach. Please take a look at the following script:
...Code:#!/app/Python/2.4/bin/python import time from threading import Thread, Event ################################################################################ # USER DEFINED CLASSES ################################################################################
Leave a comment:
-
Hi,
I have found some examples that, i believe, worked as you described. But there is one difference (at least from my point of view but since I am new in this kind of programming, I might be wrong :-) ) that it is controlled from the same class. So there is a class that has to create for instance 10 connections to the server. Each connection is a separate thread. Since they all share the same code every thread has access to the self._stopEvent ....Leave a comment:
-
Communication between threads
Hi,
I am writing a Python script that will start two threads: one thread shall start the client application and catch logs from it and the other thread shall catch logs from the server side.
So the first thread knows when it shall stop since it has a set of actions to be performed and when all it's tasks are done it simply terminates.
Now i would like the other thread to terminate itself as soon as the first thread is gone.... -
Hi,
Thanks for quick reply! I just found the cause of the problem. It was, as cybervegan has written, the type of paramters passed to the constructor. Now it works as it should!
Thanks again!
Best regards,
BiernyLeave a comment:
-
spawn problem
Hi,
I am quite new to Python but i found it really interesting and useful so I am trying to write even the smallest tools in this language. During this passion of creating everything in Python I get stuck on the following problem.
I want to create a simple class that will be used as an interface to some application. The class shall start the application as a separate thread and try to connect to it. So, it looks like this...
No activity results to display
Show More
Leave a comment: