I want to run a command over SSH and make it loop until my variable has read all the lines from a file .
I have this :
$channel = $ssh->channel();
$channel->exec('echo -n "$command"')
$channel->exec('rest of commands')
What I need to do is to run that echo command with the variable being each line from my local file /home/variables in a loop.
It should keep looping the echo command until all the lines from my file are finished before it moves to the rest of the script.
I thought I should use something like :
open my $enable, '<', '/home/variables';
while (my $command = <$enable>) {
chomp $command;
$channel->exec("echo -n $command");
last;
$channel->exec('next command');
It's not really looping though .
Thanks in advance