Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Below is my code and also the remote file format
that i have to append.
#!/usr/bin/perl -w $arg=$ARGV[0]; $arg1=$ARGV[1]; $prompt = "bash-2.03\#"; #print "$prompt\n"; use Net::Telnet; $telnet = new Net::Telnet(Timeout=>10,prompt=>"/$prompt/i",Errmode=>'d +ie'); $telnet->open("xxx.xx.xxx.xxx"); $telnet->waitfor('/login: $/i'); $telnet->print('xxxx'); $telnet->waitfor('/password: $/i'); $telnet->print('xxxxxx'); $telnet->waitfor("/$prompt/i"); @arr=$telnet->cmd('cat aa.txt'); foreach(@arr) { @arr1=split/:/,$_; if($arr1[0]=~/$arg/) { print"user exist\n"; } else { @arr=push @arr,$arg1; print @arr; } } print @arr;
the above script will opens the file from remote server,#remote file format that i have to append.<br> <fileformat> root:x:0:1:Super-User:/:/usr/bin/bash daemon:x:1:1::/: bin:x:2:2::/usr/bin: chan sys:x:3:3::/: adm:x:4:4:Admin:/var/adm: lp:x:71:8:Line Printer Admin:/usr/spool/lp: chan uucp:x:5:5:uucp Admin:/usr/lib/uucp: nuucp:x:9:9:uucp Admin:/var/spool/uucppublic:/usr/lib/uucp/uucico listen:x:37:4:Network Admin:/usr/net/nls: nobody:x:60001:60001:Nobody:/: noaccess:x:60002:60002:No Access User:/: nobody4:x:65534:65534:SunOS 4.x Nobody:/: sundarab:x:11301:237:Sundara BHARATHI:/home/users/sundarab:/bin/ksh andccadm:x:11351:237:ANDDSLAM CC Admin:/home/users/andccadm:/bin/ksh drobrech:x:11354:237:Dirk ROBRECHTS:/home/users/drobrech:/bin/ksh vponnach:x:11321:237::/home/users/vponnach:/bin/ksh krobert:x:11356:237:Kim Robertson:/home/users/krobert:/bin/ksh mamir:x:11357:237:Malik Amir:/home/users/mamir:/bin/ksh dcornfie:x:11358:237:Damian Cornfield:/home/users/dcornfie:/bin/ksh herbruge:x:11359:237:Eddy Van Herbruggen:/home/users/herbruge:/bin/ksh wiesem:x:11360:237:Marc WIESE:/home/users/wiesem:/bin/ksh matheeum:x:11361:237:Maurice MM MATHEEUSSEN:/home/users/matheeum:/bin/ +ksh borremak:x:11362:237:Kris BORREMANS:/home/users/borremak:/bin/ksh bekaerte:x:11363:237:Emmanuel BEKAERT:/home/users/bekaerte:/bin/ksh hoofp:x:11364:237:Patrick VAN HOOF:/home/users/hoofp:/bin/ksh straetri:x:11365:237:Rik VERSTRAETE:/home/users/straetri:/bin/ksh ayazt1:x:11366:237:Tamer AYAZ:/home/users/ayazt1:/bin/ksh denbroep:x:11367:237:Philippe VAN DEN BROEK:/home/users/denbroep:/bin/ +ksh aertsb:x:11368:237:Bert AERTS:/home/users/aertsb:/bin/ksh hermanjo:x:11369:237:Johan HERMANS:/home/users/hermanjo:/bin/ksh
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How to append the remote file by using Net::Telnet module
by jettero (Monsignor) on Dec 14, 2006 at 17:50 UTC | |
|