473,544 Members | 1,809 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ARGV doesn't work on Windows 2008?

dlite922
1,584 Recognized Expert Top Contributor
A script stopped working when I moved it from Win 2003 server to Win 2008. After some troubleshooting it seems that it was not grabbing the command line parameters.

So I did a print $ARGV and exit at the beginning of the file and I get this:

Expand|Select|Wrap|Line Numbers
  1. Use of uninitialized value $ARGV at .... line X
  2.  
I'm using perl from a folder, not installed or in window's path.

Thanks!


Dan
Oct 12 '10 #1
10 3681
RonB
589 Recognized Expert Moderator Contributor
$ARGV is a scalar variable. What you're wanting is @ARGV which is an array.

I you want to post your script and how you're executing it, we should be able to find the problem.
Oct 12 '10 #2
dlite922
1,584 Recognized Expert Top Contributor
Sorry, that's a PHP->Perl mistake.

There isn't any script, just this:

Expand|Select|Wrap|Line Numbers
  1.  
  2. print "Testing ARGV...\n"; 
  3. print @ARGV;
  4. print #$ARGV;
  5.  
  6.  
It prints an empty line after that message of course.
Oct 13 '10 #3
RonB
589 Recognized Expert Moderator Contributor
Syntax error, change:
Expand|Select|Wrap|Line Numbers
  1. print #$ARGV;
to:
Expand|Select|Wrap|Line Numbers
  1. print $#ARGV;
Or a better method to see what's in the array.
Expand|Select|Wrap|Line Numbers
  1. use Data::Dumper;
  2. print Dumper \@ARGV;
Oct 13 '10 #4
dlite922
1,584 Recognized Expert Top Contributor
yes, that was a typo, I apologize. It remains the same though, still doesn't work.

Whatever it takes to convince you :)

here's my file now:

Expand|Select|Wrap|Line Numbers
  1. use Data::Dumper;
  2. print Dumper \@ARGV;
  3.  
Here's the output on Win 2k8:
Expand|Select|Wrap|Line Numbers
  1. C:\>test.pl test test test
  2. $VAR1 = [];
  3.  
Weird huh? Code works fine on my XP PC.

Output On XP:
Expand|Select|Wrap|Line Numbers
  1.  
  2. C:\tmp>test.pl test test test
  3. $VAR1 = [
  4.           'test',
  5.           'test',
  6.           'test'
  7.         ];
  8.  
  9.  
  10.  
I'm out of ideas. Googled with no avail.


Dan
Oct 13 '10 #5
RonB
589 Recognized Expert Moderator Contributor
Your file type association is not setup correctly.

Run a test by executing your script like this:
C:\>perl test.pl test test test
Oct 13 '10 #6
numberwhun
3,509 Recognized Expert Moderator Specialist
This is most puzzling because I have worked on both windows platforms you mentioned, doing Perl development of course, and never experienced this issue. I am anxious to see what happens with Ron's last suggestion.
Oct 13 '10 #7
RonB
589 Recognized Expert Moderator Contributor
It's been my experience that this is a common problem when the OP has never installed perl and is using a port which makes you set these types of settings without a supplying any defaults.

The action attribute of the open setting within the file type association should be set to something like this:
"C:\Perl64\bin\ perl.exe" "%1" %*
The key part being:
"%1" %*
which sets/allows for the acceptance of the script arguments aka @ARGV. Calling the perl interpreter directly and passing it the script and args will "get around" the problem, but is not the best/proper solution.
Oct 14 '10 #8
numberwhun
3,509 Recognized Expert Moderator Specialist
Agreed! Lets see what happens when they run it.
Oct 14 '10 #9
dlite922
1,584 Recognized Expert Top Contributor
Ron was exactly right.

I half-heatedly explained that perl is not installed, but since it "worked" I didn't have any technical reasons why ARGV wouldn't work.

It does have to do with file association, because like he said when I gave my file to perl.exe it worked!

Expand|Select|Wrap|Line Numbers
  1.  
  2. C:\temp\Perl64\bin>perl.exe C:\test.pl test test test
  3. $VAR1 = [
  4.           'test',
  5.           'test',
  6.           'test'
  7.         ];
  8.  
  9.  
Awesome! Thank you.

Why not installed? This is a loaned/borrowed server and want to return it in the same exact shape I got it. (Running everything from inside a folder makes for easy cleanup later)

Thanks guys,


Dan
Oct 14 '10 #10

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

Similar topics

2
2359
by: jerry | last post by:
I'm trying to run an application under another user within a winform app writen in C#. I have tried a number of different things, but it seems that the CreateProcessWithLogonW function should work to do what I need to do. This appears to work just fine in Windows 2000 and XP with service pack 1, but it doesn't work with XP service pack 2...
4
1853
by: PengYu.UT | last post by:
The following shows the source code and the error message(from g++-3.3). I wrote two assignment operator. One is for the same type case, the other one is for different type case. I'm wondering why it doesn't work. The error line is marked with comments in the source code. Thanks, Peng
10
1797
by: Sourcerer | last post by:
I wrote this very simple code in .NET VC++. I compiled it on my system, and tried to run it on my friend's computer (he doesn't have the compiler). We both have Windows XP Professional. I have .NET framework 2.0, and he had 1.0 and it didn't work; then he installed 2.0 and it still didn't work; so he tried with 2.1 and it didn't work, then 3.0...
7
12981
by: Sin Jeong-hun | last post by:
Hi. I need to simulate keyboard and mouse events. For the first step, I tried to move mouse using SendInput. But it didn't work. I searched all over the internet for an example, but only questions were there. Please give me what was wrong in the following code. I simplified the code so that you can just copy it to a console app project, and...
0
1319
by: silkodyssey | last post by:
I recently installed the release version of visual c#2008 and I decided to test it with a wpf application. I tried dragging controls to the form but it doesn't work, the controls do not appear on the form. I tried reinstalling c# and the .net framework but it doesn't have any effect on the problem. I decided recently to install vb 2008 to see...
3
1523
by: cosmos22 | last post by:
The loop below doesn't work, I was wondering if anyone can help me. I need to create an infinate loop around the while condition. The error states that 'd' is undeclared Thank you all :) #include "windows.h" #include "winioctl.h" #include <string> #include <iostream>
4
5797
by: =?Utf-8?B?QXZhRGV2?= | last post by:
ASP.Net 2. We are migrating to Windows 2008 64 bit Server with IIS 7 from Windows 2003 32 Bit with IIS 6. A few library classes we wrote uses impersonation in code like explained in this article: http://support.microsoft.com/?id=306158#4 This doesn't work in Windows 2008 Server, we receive the following exception:
1
3824
by: Andy B | last post by:
I have the following code and can't quite figure out why it doesn't work. in the first section, I am trying to take the data from a entity framework function import and use it inside a repeater. <asp:Repeater ID="Repeater1" runat="server"> <ItemTemplate> <% #Bind("Title") %> </ItemTemplate> </asp:Repeater>
3
689
by: =?Utf-8?B?Um9nZXIgTWFydGlu?= | last post by:
Note: My apologies for repeating this post from last week, but my nospam alias and profile account were incorrect. I think I have fixed this, so hopefully this post will trigger MS into a response per their MSDN policy. -------------------- I have a web site under .NET 2.0 that renders videos using the Silverlight media player. The web...
4
2826
by: BuildHome | last post by:
Hello, I have windows 2008 R2 and IIS 7.5 with PHP 5.2.4. I've tried to upgrade to PHP 5.3.3 and the same problem. I'm using WORDPRESS or phpmyadmin that need to use session. I've enabled and gave the folder write permissions. When I'm trying to use the session its created but its forgotten...
0
7413
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7356
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7597
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7752
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7358
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
1
5286
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4902
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3396
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
980
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.