473,395 Members | 2,795 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

ARGV doesn't work on Windows 2008?

dlite922
1,584 Expert 1GB
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

✓ answered by RonB

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.

10 3677
RonB
589 Expert Mod 512MB
$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 Expert 1GB
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 Expert Mod 512MB
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 Expert 1GB
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 Expert Mod 512MB
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 Expert Mod 2GB
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 Expert Mod 512MB
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 Expert Mod 2GB
Agreed! Lets see what happens when they run it.
Oct 14 '10 #9
dlite922
1,584 Expert 1GB
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
numberwhun
3,509 Expert Mod 2GB
I am certainly glad that Ron's suggestion was the issue. On another note, specifically the issue of returning the server in the condition you found it, portable apps are your friend. In fact, Strawberry Perl has a portable version that you can put on a stick. Enjoy!
Oct 16 '10 #11

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

Similar topics

2
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...
4
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...
10
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...
7
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...
0
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...
3
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 :) ...
4
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...
1
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. ...
3
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...
4
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...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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,...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.