468,247 Members | 1,468 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,247 developers. It's quick & easy.

How to run system commands through perl script in Windows Server 2008 R2?

For example,runnig "ipconfig" command through perl script and printing it on web browser.
Expand|Select|Wrap|Line Numbers
  1. my $cmd = "ipconfig";
  2. my $output = `$cmd`;
  3. print $output;
  4.  
Above code works fine in Windows Server 2003,but $output is null in Windows Server 2008 R2.

Done necessary settings in IIS for perl,is there additional settings in windows server 2008 R2 for perl?
Is there a way to make above mentioned code to work in Windows Server 2008 R2.
Using perl 5.6 version.


Appreciate your help.
Jan 28 '11 #1
8 8996
numberwhun
3,503 Expert Mod 2GB
@output will definitely be null. In the code you provided above, you are storing it in $output. Two totally different containers.
Jan 29 '11 #2
Sorry ,@output is typo mistake,it is $output.
Jan 30 '11 #3
chorny
80 Expert
1. Try running it from command line. Does it work?

2. Try using system instead of ``. Does it return any error?
Jan 30 '11 #4
Thanks for quick reply
1.It does works through command prompt.
2.system returns 0.
Jan 30 '11 #5
chorny
80 Expert
It is possible that IIS runs command with lowered privileges.

Try running it as `$cmd 2>&1`. Does it return any error message?
Jan 30 '11 #6
It returns NULL,
How can I increase previlages in IIS?
Iam trying to run web Application in windows server 2008 R2 which works fine in Windows Server 2003.Web app uses both perl and cgi.Several pages are not working because of system command call using backtik.
One more thing I tried redirecting output to file,which is working.Since there are lot files using system command I do not want do this.
Need your valuable suggestions.
Jan 31 '11 #7
we have got the same problem. Have you found a solution or at least the reasons why the backtick command in perl suddenly doesn't work with windows server 2008 r2.
Jun 9 '11 #8
RonB
589 Expert Mod 512MB
Try specifying the full path or use a module which extracts the info from the registry.

Win32::IPConfig
Jun 10 '11 #9

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

3 posts views Thread by =?Utf-8?B?T2xpdmllciBNQVRST1Q=?= | last post: by
2 posts views Thread by Odd B Andersen | last post: by
1 post views Thread by =?Utf-8?B?bWFzYWtpeQ==?= | last post: by
1 post views Thread by =?Utf-8?B?QW50amU=?= | last post: by
reply views Thread by NPC403 | last post: by
reply views Thread by kermitthefrogpy | last post: by
reply views Thread by zattat | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.