Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

connect to central webserver and acces a file

by chennaiite (Sexton)
on Aug 18, 2005 at 12:31 UTC ( #484727=perlquestion: print w/ replies, xml ) Need Help??
chennaiite has asked for the wisdom of the Perl Monks concerning the following question:

I want to connect to a central server and i have to make changes on c:/winnt/..../..

Is there any script to do this...

#!/usr/bin/perl use Net::Telnet; print "Enter IP"; my $var=<STDIN>; chomp $var; print "Enter User"; my $user=<STDIN>; chomp $user; print "Enter Password"; my $pass=<STDIN>; chomp $pass; #$telnet = new Net::Telnet->new( Timeout=>100,Prompt => '/[\$%#>] $/') +; $telnet = new Net::Telnet->new( Timeout=>100 ); $telnet->open($var); $telnet->login($user,$pass); #SAMPLE copy $telnet->cmd("echo $1 > file"); $telnet->close;
why this script is not working

CODE tags added by Arunbear

Comment on connect to central webserver and acces a file
Download Code
Re: connect to central webserver and acces a file
by davidrw (Prior) on Aug 18, 2005 at 12:44 UTC
    What service (e.g. telnet or ssh server or windows file sharing or ftp server or web/cgi, etc) is running on the central server that will allow you to connect and modify files? You have to define that first then we can point you to the appropriate perl implementation. Also, what type of changes? If it's something simple a perl -i -pe '' command may suffice.. which brings up the question, is perl installed on the central server? If not, you'll have to pull the file back, make your changes, and push it back.
Re: connect to central webserver and acces a file
by SimonClinch (Chaplain) on Aug 18, 2005 at 12:48 UTC
    If the changes are intended to be done manually, as opposed to having a regular and predictable form, then it seems extreme overkill to use perl, rather than a normal ftp access to the directory.

    Otherwise, for automated changes, perl does not provide off-the-shelf scripts, rather CPAN provides modules to assist the programmer in writing such scripts. In this case, Net::FTP provides an o-o model that is easy to use (provided you know the basics of perl o-o programming).

    Update: Some code has arrived in the OP meanwhile, but it could do with some code tags.

    One world, one people

Re: connect to central webserver and acces a file
by larryp (Deacon) on Aug 18, 2005 at 15:24 UTC

    Please take a look at Writeup Formatting Tips to learn how to format your posts properly. In this case, please pay special attention to the section on <code> tags.

    Closely following those guidelines will help you get your questions answered more quickly...and it will help other monks in answering them.

Re: connect to central webserver and acces a file
by SimonClinch (Chaplain) on Aug 18, 2005 at 15:44 UTC
    I can't install Net in my daily environment, but there are a few ways to narrow this down:

    - it would help if we can see what output is sent to STDOUT and what to STDERR.

    - similarly what is the output to channels 1 and 2 when you try it with a telnet session instead of using perl.

    One world, one people

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://484727]
Approved by aukjan
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (7)
As of 2014-12-28 03:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (178 votes), past polls