auyong has asked for the wisdom of the Perl Monks concerning the following question:
Animator, thanks for your input and advise. The reason I had the $write_file is because I have additional logic to decide whether I want to write or append but I guess I could have incorporated the three-param version into my logic instead of having the scalar $write_file.my $write_file=">"; my $initial_data = 'file.txt'; my $dumpfile='storage_dumpfile.txt'; my $inputfile='inputfile.txt'; my $storage_file=$write_file.$directory.'storage_final_file.txt'; open(STORAGE_FILEHANDLE, $storage_file)||die ("Cannot open file please + check if file exists"); $storage_telnet = Net::Telnet->new ( Timeout=>10, Prompt=>'/>/', Dump_Log=>$dumpfile, Input_log=>$inputfile ) or die("Cannot establish connection"); $storage_telnet->login($_[2], $_[3])||die("Cannot login, pleas +e check password\n", dump_log=>$dumpfile); $storage_telnet->cmd ("cd\\Program Files\\Hi\\DManager\\HiCLI\\")|| di +e (dump_log=>$dumpfile); @df=$storage_telnet->cmd(String=>"dir", Prompt=>'/C:\\\\Program Files\ +\\\Hi\\\\DManager\\\\HiCLI*/i')||die(dump_log=>$dumpfile); ##mkdir works, the new directory whatthehell was created ##this was just used to test whether I am in the correct ##directory #@df=$storage_telnet->cmd(String=>"mkdir whatthehell", Prompt=>'/C:\\\ +\Program Files\\\\Hi\\\\DManager\\\\HiCLI*/i')||die(dump_log=>$dumpfi +le); #here $write_file = ">" open (INITIAL_RAW_DATA_FILEHANDLE, $write_file.$initial_data); foreach $element(@df) { print INITIAL_RAW_DATA_FILEHANDLE "$element\n"; } close(INITIAL_RAW_DATA_FILEHANDLE);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Capturing Telnet Command Outputs on Windows 2000 machines
by Animator (Hermit) on Feb 17, 2005 at 19:09 UTC | |
|
Re: Capturing Telnet Command Outputs on Windows 2000 machines
by Mr. Muskrat (Canon) on Feb 19, 2005 at 14:51 UTC | |
|
Re: Capturing Telnet Command Outputs on Windows 2000 machines
by castaway (Parson) on Feb 19, 2005 at 11:04 UTC |