telnet read_sb_data

A

Arne

Hello!

Task: Connecting to a unix server and getting the directory list .
OS: XP

Connecting to the server via telnet is no problem.
I also want to get the directory list. I know by using read_all I can get
all the output (starting from the login up to the end).
1. What I look for is the option to get only certain parts of the output. It
seems to me that the command "read_sb_data" can do this. The documentation
says, that I will get the data between the SB/SE pair. But I don't know how
to invoke the SE command in Unix. Even I don't know the SE command.

2. I thing when this command work I can also get the directory size for each
directory in root (using df and du Unix commands)
Using os.stat(path) doesen't work on XP, I am always getting a 0 return
(i.e. (16895, 0L, 3, 1, 0, 0, 0L, 315529200, 315529200, 315529200))

Please be so kind and post a little bit of a code.

Thanks a lot!
Arne
 
D

Dennis Lee Bieber

1. What I look for is the option to get only certain parts of the output. It
seems to me that the command "read_sb_data" can do this. The documentation
says, that I will get the data between the SB/SE pair. But I don't know how
to invoke the SE command in Unix. Even I don't know the SE command.
Did you read the full documentation? "SB/SE" are "suboption
begin/end", and there is also mention of a "callback". The ONLY other
entry in telnetlib that mentions callbacks is the one for negotiating
telnet options.

read_sb_data( )
Return the data collected between a SB/SE pair (suboption begin/end).
The callback should access these data when it was invoked with a SE
command. This method never blocks.

set_option_negotiation_callback( callback)
Each time a telnet option is read on the input flow, this callback (if
set) is called with the following parameters : callback(telnet socket,
command (DO/DONT/WILL/WONT), option). No other action is done afterwards
by telnetlib.

Using os.stat(path) doesen't work on XP, I am always getting a 0 return

No surprise -- os.stat can only access files mounted on the local
machine. Telnet is remote /terminal/ connection. You'll have to behave
like a terminal... How would you, as a user at a terminal, know when any
command had finished? Probably by seeing a console prompt...

Try

read_until( expected[, timeout])
Read until a given string, expected, is encountered or until timeout
seconds have passed.
When no match is found, return whatever is available instead, possibly
the empty string. Raise EOFError if the connection is closed and no
cooked data is available.

You'll have to know what the prompt string will be...
--
 
A

Arne

Thank you for your reply.

Yes I have read the documentation. But I am not sure what is the SB/SE
suboption. Is this a suboption on the remote machine or for Python.
Maybe you could be so kind and explain it to me with a little code example.

Thany you very much!
Arne

Dennis Lee Bieber said:
1. What I look for is the option to get only certain parts of the output.
It
seems to me that the command "read_sb_data" can do this. The
documentation
says, that I will get the data between the SB/SE pair. But I don't know
how
to invoke the SE command in Unix. Even I don't know the SE command.
Did you read the full documentation? "SB/SE" are "suboption
begin/end", and there is also mention of a "callback". The ONLY other
entry in telnetlib that mentions callbacks is the one for negotiating
telnet options.

read_sb_data( )
Return the data collected between a SB/SE pair (suboption begin/end).
The callback should access these data when it was invoked with a SE
command. This method never blocks.

set_option_negotiation_callback( callback)
Each time a telnet option is read on the input flow, this callback (if
set) is called with the following parameters : callback(telnet socket,
command (DO/DONT/WILL/WONT), option). No other action is done afterwards
by telnetlib.

Using os.stat(path) doesen't work on XP, I am always getting a 0 return

No surprise -- os.stat can only access files mounted on the local
machine. Telnet is remote /terminal/ connection. You'll have to behave
like a terminal... How would you, as a user at a terminal, know when any
command had finished? Probably by seeing a console prompt...

Try

read_until( expected[, timeout])
Read until a given string, expected, is encountered or until timeout
seconds have passed.
When no match is found, return whatever is available instead, possibly
the empty string. Raise EOFError if the connection is closed and no
cooked data is available.

You'll have to know what the prompt string will be...
--
============================================================== <
(e-mail address removed) | Wulfraed Dennis Lee Bieber KD6MOG <
(e-mail address removed) | Bestiaria Support Staff <
============================================================== <
Home Page: <http://www.dm.net/~wulfraed/> <
Overflow Page: <http://wlfraed.home.netcom.com/> <
 
G

Grant Edwards

Yes I have read the documentation. But I am not sure what is
the SB/SE suboption. Is this a suboption on the remote machine
or for Python. Maybe you could be so kind and explain it to me
with a little code example.

SB/SE are used for telnet protocol option negotation for telnet
protocol options that are more complicated that just on/off.
It has absolutely nothing to do with what you're trying to do.

For more info, read the RFC on the telnet protocol option
negotiation:

http://www.faqs.org/rfcs/rfc855.html

Here's another decent article:

http://www.scit.wlv.ac.uk/~jphb/comms/telnet.html
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,143
Latest member
DewittMill
Top