求助:关于用$telnet->cmd('cd $dir')切换目录问题

求助:关于用$telnet->cmd('cd $dir')切换目录问题

use Net::Telnet;
my $ip1="192.168.11.25";
my $username1="toptea";
my $passwd1="utopteaabc";
my $dir1="/export/home/toptea/toptea_release";
my $telnet=Net::Telnet->new($ip1);
$telnet->login($username1,$passwd1);
$telnet->cmd('cd $dir1');
my @lines =$telnet->cmd('echo $?');
my @lines1 = $telnet->cmd('du -sk');
#print $lines[0];
print $lines1[0];
my @size = split(' ',"$lines1[0]",0);
$size1 = $size[0];
print $size1;
脚本如上:用$telnet->cmd('cd $dir1');并没有切换到我想要的目录


[Copy to clipboard] [ - ]
CODE:
$telnet->cmd("cd $dir1");

$telnet->cmd("cd $dir1");

perl 里 ' '中是不可以直接放$dir1这样的变量的。如果放在里面它会把它当作字符串。