From: <RGi...@a1...> - 2002-05-23 11:20:34
|
=3E I have a first perl/expect script attempt going=2E I have the main =3E structure and loop set up=2E It=27s working fine=2E I=27m trying to= ssh = =3E to a remote server to execute a command=2E I then want to funnel =3E the output back to an array=2E =3E = =3E Does anyone have anything similar I can take apart and learn from=3F = =3E A couple of the problems I=27m hitting=2E How do I turn off echo fro= m my =3E spawn commands=3F How do I shove my output back into my array=3F I=27= m not =3E seeing a method for this=2E First=2C have you noted the following two FAQs=3F I want to automate password entry for su/ssh/scp/rsh/=2E=2E=2E You shouldn=27t use Expect for this=2E Putting passwords=2C especially root passwords=2C into scripts in clear text can mean severe security problems=2E I strongly recommend using other means=2E For =27su=27=2C consider switching to =27sudo=27=2C w= hich gives you root access on a per-command and per-user basis without the need to enter passwords=2E =27ssh=27/=27scp=27 can be se= t up with RSA authentication without passwords=2E =27rsh=27 can use the =2Erhost mechanism=2C but I=27d strongly suggest to switch to =27ssh=27=3B to mention =27rsh=27 and =27security=27 in the same sent= ence makes an oxymoron=2E It will work for =27telnet=27=2C though=2C and there are valid uses for it=2C but you still might want to consider using =27ssh=27=2C as keeping cleartext passwords around is very insecure=2E I want to use Expect to automate =5Banything with a buzzword=5D=2E=2E=2E= Are you sure there is no other=2C easier way=3F As a rule of thumb=2C Expect is useful for automating things that expect to talk to a human=2C where no formal standard applies=2E For other tasks that do follow a well-defined protocol=2C there are often better-suited modules that already can handle those protocols=2E Don=27t try to do HTTP requests by spawning telnet to port 80=2C use LWP instead=2E To automate FTP=2C take a look at the Net=3A=3AFTP manpage or =22ncftp=22 (http=3A//www=2Encftp=2Eorg)=2E You don=27t use a screwdriver to hammer in your nails either=2C or do you=3F So=2C how about using =27=24output =3D qx(ssh =24host =24command)=27=3F The Expect manpage contains a source example how to automate telnet = login=2C which might be of interest=2E See also the entry for =27log=5Ff= ile=27=2E = Apart from that=2C how about matching line for line and stuffing that = into an array=3F E=2Eg=2E =24exp-=3Eexpect(=24timeout=2C =5B qr/=2E*=5Cn/ =3D=3E sub =7B my =24self= =3D shift=3B push = =40array=2C =24self-=3Ematch()=3B exp=5Fcontinue=3B =7D =5D)=3B Hope this helps=2C Roland -- RGiersig=40cpan=2Eorg ----- Urspr=FCngliche Nachricht ----- Von=3A =22Robert L=2E Harris=22 =3CRobert=2EL=2EHarris=40rdlg=2Enet=3E Datum=3A Dienstag=2C Mai 21=2C 2002 6=3A50 pm Betreff=3A =5BExpectperl-discuss=5D New Script =3E = =3E = =3E First post=2C hopefully on topic=2E =3E = =3E = =3E = =3E =3Awq! =3E ------------------------------------------------------------------- =3E -------- =3E Robert L=2E Harris =7C Micros=7E1 =3A =3E Senior System Engineer =7C For when quality=2C reliabilit= y =3E at RnD Consulting =7C and security just aren=27t =3E =5C=5F that important! =3E DISCLAIMER=3A =3E These are MY OPINIONS ALONE=2E I speak for no-one else=2E =3E FYI=3A =3E perl -e =27print =24i=3Dpack(c5=2C(41*2)=2Csqrt(7056)=2C(unpack(c=2CH= )- =3E 2)=2Coct(115)=2C10)=3B=27 =3E = =3E =5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F= =5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F= =5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F =3E = =3E Don=27t miss the 2002 Sprint PCS Application Developer=27s Conference= =3E August 25-28 in Las Vegas -- http=3A//devcon=2Esprintpcs=2Ecom/adp/in= dex=2Ecfm =3E = =3E =5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F= =5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F =3E Expectperl-discuss mailing list =3E Expectperl-discuss=40lists=2Esourceforge=2Enet =3E https=3A//lists=2Esourceforge=2Enet/lists/listinfo/expectperl-discuss= =3E |