Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Need to Execute msiexec using Net::Telnet

by tarunmudgal4u (Sexton)
on Aug 26, 2012 at 20:56 UTC ( #989877=perlquestion: print w/ replies, xml ) Need Help??
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.

Comment on Need to Execute msiexec using Net::Telnet
Select or Download Code
Re: Need to Execute msiexec using Net::Telnet
by philiprbrenan (Monk) on Aug 26, 2012 at 22:15 UTC

    Could you clean up your example removing all extraneous information, comments, etc. Place a say dump($command) just before the failing statement so that we can see exactly what is being executed. Please make sure you are including /q in the command string so that msi does not attempt to start in GUI mode. Also, please make sure that you are presenting the smallest possible command that does in fact fail with all possible defaults taken so that the failure can be localized as much as possible.

    As you are telnetting, you should not need an ip or host name at the front of your file name, it should be a local file on the target machine.

    Ideally you should run the desired command on the target machine (by walking over to it and typing it in) to prove that you have the correct syntax before attempting to execute the command via telnet.

    Could you also demonstrate that you can run simple commands like "dir", "cd" etc. via telnet to prove that the environment is operational.

    These actions should make the cause of the failure much clearer.

    Thanks

      Hi Philip,

      I used these commented lines just to show that I've tried all these options, but, none of them is working :(. For you, I've copied lines of code that is being executed. Please see below code-

      use Net::Telnet; BEGIN { $|=1 } $user = "administrator"; $pass = 'pass'; $telnet = new Net::Telnet ( Timeout=>20, Errmode=>'die', Prompt => '/[ +%#>] ?$/', Dump_Log=>"dumplogs.txt", Input_log=>"inputlogs.txt", O +utput_log=>"outputlogs.txt"); $telnet->open('xx.xx.xx.xx'); $telnet->login(Name=>$user, Password=>$pass, Prompt => '/[%#>:] ?$/'); $command = qq(msiexec \/qn \/i \\\\10.210.156.150\\SEP_Builds\\Jaguar\ +\Integration\\940\\DVD-SEP-EE\\SEPx64\\Sep64.msi \/norestart RUNLIVEU +PDATE=0 \/l\*v C:\\Compatibility_Automation_Temp\\SepClientInstallLog +.txt); print "command is: [$command]\n"; @output = $telnet->cmd(String=>$command); print "output is:\n@output\n"; exit;
      The output of this command seen from the "inputlogs.txt" is mentioned below-
      Welcome to Microsoft Telnet Service login: administrator password: *=============================================================== Microsoft Telnet Server. *=============================================================== C:\Users\Administrator>msiexec /qn /i \\10.210.156.150\SEP_Builds\Jagu +ar\Integration\940\DVD-SEP-EE\SEPx64\Sep64.msi /norestart RUNLIVEUPDA +TE=0 /l*v C:\Compatibility_Automation_Temp\SepClientInstallLog.txt C:\Users\Administrator>
      Now, if I copy and paste the same command I see in inputlogs.txt file, this command works well on remote mahcine. but using this script, it doesn't. Please help me with this.

        We are making progress. The nest step is to prove that you can execute a simple command on the target machine via Telnet. The ideal command would be perl -v so that we can see that we can start perl remotely. Once that done we can put the desired msiexec command in a perl script on the target machine and start that. So: can you execute perl remotely via Telnet on the target machine?

Re: Need to Execute msiexec using Net::Telnet
by GrandFather (Cardinal) on Aug 26, 2012 at 23:36 UTC

    Show us the output from print "command is: [$command]\n";. If you "copy and paste" that output as a command on the failing machine does the command succeed without manual intervention (you probably want /qn, /quiet or /passive on the command line)?

    True laziness is hard work

      Hi GrandFather, I've done that. Please find below inputlogs.txt file contents after executing this script-

      Welcome to Microsoft Telnet Service login: administrator password: *=============================================================== Microsoft Telnet Server. *=============================================================== C:\Users\Administrator>msiexec /i \\10.210.156.150\SEP_Builds\Jaguar\I +ntegration\940\DVD-SEP-EE\SEPx64\Sep64.msi /norestart RUNLIVEUPDATE=0 + /l*v C:\Compatibility_Automation_Temp\SepClientInstallLog.txt C:\Users\Administrator>
      Now, when I copy paste this command from this log file to the remote machine, it works well. Please let me know what should I try now.

        earlier I was using /qn option itself, but, while searching some solution on google, I fould, I should use /q only. But, anyways, none of them is working :(

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://989877]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (8)
As of 2014-10-01 07:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (389 votes), past polls