Net::Telnet => Will cd ( change directory ) command work ?

Net::Telnet => Will cd ( change directory ) command work ?

am 27.02.2006 09:44:44 von Vinod k

Hi All,

I am new to this module, Net::Telnet. Pls let me know, once you logged
in to a remote system using telnet module in perl, is it possible to
change directory in romote session ? I tried, but i am not able to do
so.

Thanks in advance,
Vinod.

Re: Net::Telnet => Will cd ( change directory ) command work ?

am 27.02.2006 14:25:57 von Paul Lalli

Vinod k wrote:

> I am new to this module, Net::Telnet. Pls let me know, once you logged
> in to a remote system using telnet module in perl, is it possible to
> change directory in romote session ? I tried, but i am not able to do
> so.

You tried? How? Where is your code that fails to work as expected?

How can anyone help you see where you went wrong if you don't show us
what you tried?

Paul Lalli

Re: Net::Telnet => Will cd ( change directory ) command work ?

am 28.02.2006 15:54:48 von Charles DeRykus

Vinod k wrote:

> I am new to this module, Net::Telnet. Pls let me know, once you logged
> in to a remote system using telnet module in perl, is it possible to
> change directory in romote session ? I tried, but i am not able to do
> so.

Hm, should be possible. You could do something like this to trap
whether an error occurred since cd wouldn't output anything if
successful:

my $telnet = Net::Telnet->new( ... );
$telnet->cmd_remove_mode(1); # omit command echo from output
my @output = $telnet->cmd('cd /path/to/somewhere')
die "cd error: @output\n" if @output;

If on my Unix system I try to cd to a directory without having privilege
to do so, the above dies with:

ksh: /path/to/somewhere: permission denied

There may be a more general way....

HTH,
--
Charles DeRykus