Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

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

Replies are listed 'Best First'.
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 (Deacon) 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 SimonClinch (Deacon) 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

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.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://484727]
Approved by aukjan
[Corion]: Option a) would mean launching cmd.exe /k c:\path\to\ batchfile- launching-perl- script.cmd. Option b) would be to add pause as the last line of said batch file.
[LanX]: First day after holidays ... and already stressed by the fact that colleagues changed stuff without communication ... apparently I'm the only one trying to fight entropy
[Corion]: LanX: The command is always in the history if you typed it in before. If you didn't type the command into the command line, it will not be there. I think there is doskey which can stuff command lines into the history
LanX damns the cult of CB ;-)
[LanX]: please forget my last 3 posts
[LanX]: Yeah option a doesn't go into history
[LanX]: probably I need to teach the app to restart after C-c Kill
[Corion]: LanX: Maybe have an infinite-loop cmd file? Much easier than trying to manage that from within Perl IMO
[Corion]: Alternatively, relaunch the application from cron (or a Windows cron) every minute

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (12)
As of 2017-03-27 15:50 GMT
Find Nodes?
    Voting Booth?
    Should Pluto Get Its Planethood Back?

    Results (320 votes). Check out past polls.