* Running python from ax25d?
@ 2010-11-09 22:29 Gordon JC Pearce
2010-11-10 7:34 ` Tomi Manninen
0 siblings, 1 reply; 2+ messages in thread
From: Gordon JC Pearce @ 2010-11-09 22:29 UTC (permalink / raw)
To: linux-hams
Hi all,
I'm having some problems getting Python to work when called from
ax25d. Specifically, stdin does not seem to be passed correctly to the
script.
Example:
#!/usr/bin/python2 -u
# saved as /home/gordonjcp/test.py
# corresponding line in ax25d.conf is
# default * * * * * * - gordonjcp /home/gordonjcp/test.py test.py
import sys
a=""
print "Hello"
while(a.strip()!="stop"):
a = sys.stdin.readline()
print "you typed " + a
When I call this from the command-line, or indeed from xinetd it behaves
as expected - it starts, prints "Hello", then prints "you typed
<whatever you typed>" when you press return. If you type "stop", it
stops.
From ax25d, it prints "Hello" but does not respond to any keyboard
input. Furthermore, if I close down the connection from call(1) I get
the following:
Traceback (most recent call last):
File "/home/gordonjcp/test.py", line 7, in <module>
a = sys.stdin.readline()
IOError: [Errno 107] Transport endpoint is not connected
The IO error seems to suggest that there is no connection from stdin as
handled by ax25d to Python. I'm not sure if this is because stdin goes
away when the connection is closed, or because it was never there to
begin with.
Any thoughts?
Gordon MM0YEQ
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: Running python from ax25d?
2010-11-09 22:29 Running python from ax25d? Gordon JC Pearce
@ 2010-11-10 7:34 ` Tomi Manninen
0 siblings, 0 replies; 2+ messages in thread
From: Tomi Manninen @ 2010-11-10 7:34 UTC (permalink / raw)
To: Gordon JC Pearce; +Cc: linux-hams
Gordon JC Pearce wrote:
> #!/usr/bin/python2 -u
> # saved as /home/gordonjcp/test.py
> # corresponding line in ax25d.conf is
> # default * * * * * * - gordonjcp /home/gordonjcp/test.py test.py
> import sys
> a=""
> print "Hello"
> while(a.strip()!="stop"):
> a = sys.stdin.readline()
> print "you typed " + a
End-of-line problems maybe? On packet radio CR is the de facto EOL
character. Python file objects readline() method probably seeks
for a LF...
Have you tried eg. sys.stdin.read(1) to see if you get what you
wrote back one character at a time?
>>From ax25d, it prints "Hello" but does not respond to any keyboard
> input. Furthermore, if I close down the connection from call(1) I get
> the following:
>
> Traceback (most recent call last):
> File "/home/gordonjcp/test.py", line 7, in <module>
> a = sys.stdin.readline()
> IOError: [Errno 107] Transport endpoint is not connected
>
> The IO error seems to suggest that there is no connection from stdin as
> handled by ax25d to Python. I'm not sure if this is because stdin goes
> away when the connection is closed, or because it was never there to
> begin with.
I'd say it's because the connection was closed. Although ENOTCONN is
a somewhat strange error here... hmm.
/Tomi
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-11-10 7:34 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-11-09 22:29 Running python from ax25d? Gordon JC Pearce
2010-11-10 7:34 ` Tomi Manninen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox