I am trying to remove my program's dependency on reading information from files and then interpreting that information. I have created a library of Perl commands that generates the necessary information on-demand. The one hang-up I am experiencing is that Perl sometimes calls an expect script and the expect script is currently designed to take in a file path, open that file, read in the information and then use that information.
Instead I would like to pass in a Perl array to the expect script that contains all of the information. Herein lies my problem: I have been struggling to figure out how an expect script handles an array as a parameter and translating that parameter into something useful.
Perl example:
my $expectCmd = "expect.sh 300 $vmIp $vmPort $pass @configInfo";
system($expectCmd);
Expect Script:
set ip [lindex $argv 1]
set port [lindex $argv 2]
set pass [lindex $argv 3]
At this point I have no idea how to read in the @configInfo array and use it. I have tried various methods of upvar, array set, for-loops, foreach loops, begging, pleading and bribing. Nothing has worked so far.
The end goal will be to send the @configInfo array line-by-line to a file. Basically, I want each index of the array to be a line in the file - if it was Perl I would just:
foreach my $line (@configInfo) {
print FILE $line;
}
If anyone has experience in passing arrays into an expect script and then unpacking their contents for use I would be very grateful for a response. Many thanks!
$expectCmdvariable and confirming it's in the correct format. The items in the array may be getting appended to each other without spacing. - Joshua