http://www.perlmonks.org?node_id=989877

tarunmudgal4u has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks,

There is one situation where I want to execute msiexec command line on remote machine using Net::Telnet.

When I execute some simple ipconfig/hostname like commands, I get proper output. but when I execute msiexec with multiple long parameters, it doesn't work. Please see below script-

use Net::Telnet; BEGIN { $|=1 } $user = "administrator"; $pass = 'abc'; $telnet = new Net::Telnet ( Timeout=>20, Errmode=>'die', Prompt => '/[ +%#>] ?$/', Dump_Log=>"dumplogs.txt", Input_log=>"inputlogs.txt", Outp +ut_log=>"outputlogs.txt"); $telnet->open('xx.xx.xx.xx'); $telnet->login(Name=>$user, Password=>$pass, Prompt=>'/[%#>:] ?$/'); #$command = qq(msiexec \/qn \/i \\\\yy.yy.yy.yy\\SEP_Builds\\Jaguar\\I +ntegration\\940\\DVD-SEP-EE\\SEPx64\\Sep64.msi \/norestart RUNLIVEUPD +ATE=0 \/l\*v C:\\Compatibility_Automation_Temp\\SepClientInstallLog.t +xt); $command = q(msiexec /i \\\\yy.yy.yy.yy\SEP_Builds\Jaguar\Integration\ +940\DVD-SEP-EE\SEPx64\Sep64.msi /norestart RUNLIVEUPDATE=0 /l*v C:\Co +mpatibility_Automation_Temp\SepClientInstallLog.txt); #$command = q(msiexec /q /i \\\\yy.yy.yy.yy\SEP_Builds\Jaguar\Integrat +ion\940\DVD-SEP-EE\SEPx64\Sep64.msi /norestart RUNLIVEUPDATE=0); #$command = "ipconfig && net use J: \\\\yy.yy.yy.yy\\Public_Share\\Ta +run"; print "command is: [$command]\n"; @output = $telnet->cmd(String=>$command); =cut @output = $telnet->cmd(join ' ', 'C:\Windows\System32\msiexec.exe', '/q', '/i', "\\\\yy.yy.yy.yy\\SEP_Builds\\Jaguar\\Integration\\940\\DV +D-SEP-EE\\SEPx64\\Sep64.msi", '/norestart', 'RUNLIVEUPDATE=0', '/l*v', 'C:\Compatibility_Automation_Temp\SepClientInstallLog.txt' +); =cut print "output is:\n@output\n"; exit;

Here, I've tried different ways to create my command line, but, none of them worked. From my local machine, when I execute this script, output shows command ran successfully on remote machine yy.yy.yy.yy but when I check it personally on yy.yy.yy.yy machine, this command didn't get executed there. Then I ran the same command on remote machine which i'm able to see inside "inputlogs.txt" file and it ran successfully.

While investing more on this, I ran a command to map my shared network drive on remote machine. you can also see this command in the above code(I've commented out that line #$command = "ipconfig  && net use J: \\\\yy.yy.yy.yy\\Public_Share\\Tarun";). Here also, I get "command completed successfully" message in inputlogs.txt wherein I didn't see any mapped network drive on rempte machine later.

Can anybody please help me out?? I would really appreciate any help or suggestion.