Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

Open: Invalid Argument

by jhs3 (Novice)
on Jun 01, 2007 at 15:47 UTC ( #618781=perlquestion: print w/replies, xml ) Need Help??
jhs3 has asked for the wisdom of the Perl Monks concerning the following question:

Perlmonks all:

... Such a simple problem I have. It is so simple, I will explain at length.

OS is WinNT 4.0. Dinosaur! Can't do anything about that!

This script I am having problems with 'used' to work. It has been working for 7 years, used hundreds of times. Recently, (thanks to Misters Sarbane/Oxley) things have changed in accessing the system.
The script normally runs from Unix, from a shell script, where 'remsh' is executed on the NT server. The script is run as the 'root' user - which I log into using 'sudo su -'.
An example of the command that is run:

# remsh kirk -n "d:\perl\bin\perl d:\qad\srcmgr\ -t -f d:\qa +d\srcmgr\prog.lst" Can't open \\kirk\QAD\TIMES2\LOG\comp_one.lst: Invalid argument
'kirk' is the NT server.

I can't figure this out, so I go to the NT server. I log in as userid 'root' - which is an Admistrator on the server. I open a 'cmd' window. I run the perl program string from the command line, and get this result:
D:\QAD\srcmgr>d:\perl\bin\perl d:\qad\srcmgr\ -t -f d:\qad\s +rcmgr\prog.lst Processing file MGURMTP.P \\kirk\QAD\MODS\US\SRC\MGURMTP.P is readable. 1 file(s) copied.
This is the result I would expect to get from running on Unix.
The perl script opens the file 'comp_one.lst'. It is in a variable, but the command that dies is:
open(COMPLIST, "> " . $CompFiles) || die "Can't open $CompFiles: $!\n" +;
OK. The script fails when I run it from Unix, but runs on the NT server. I try another thing - I delete the 'comp_one.lst' file and run it in the command window again:
D:\QAD\srcmgr>d:\perl\bin\perl d:\qad\srcmgr\ -t -f d:\qad\s +rcmgr\prog.lst Can't open \\kirk\QAD\TIMES2\LOG\comp_one.lst: Invalid argument
This tells me that the script really expects that 'comp_one.lst' file to be there so it can be opened. If it is not there, it gets the same error I get when I try to run it from the shell script on Unix.
But, when I run it from Unix, the file IS there. So, I think I am getting into some sort of permissions problem. And this may be more of an NT - permission - remsh error than a perl error. Anyone want to give me some insight here?
One definite perl question: is there a better way I can trap the error it gets when it tries to open the file? If the open fails - how can the perl program 'see' that and just create it if it isn't there, delete it and recreate it if it is there?

Replies are listed 'Best First'.
Re: Open: Invalid Argument
by FunkyMonk (Canon) on Jun 01, 2007 at 15:55 UTC
    # remsh kirk -n "d:\perl\bin\perl d:\qad\srcmgr\ -t -f d:\qa +d\srcmgr\prog.lst"

    Those backslashes won't make it through to the NT box. Either double them up, use single quotes instead of double or (I believe) you can use forward slashes instead.
      Or use single quotes instead of double.
      Update: Sorry, ignore that
Re: Open: Invalid Argument
by blazar (Canon) on Jun 01, 2007 at 15:55 UTC

    Your post is too long for me to want to read it all at this time of the day, but I noticed the line below:

    open(COMPLIST, "> " . $CompFiles) || die "Can't open $CompFiles: $!\n" +;

    and I don't know if it would make a difference, but you have and are recommended to use the three args form of open nowadays:

    open my $complist, '>' , $CompFiles or die "Can't open $CompFiles: $!\ +n";

    (I also used a lexical fh and low precedence C<or> which allows me to remove parens.)

Re: Open: Invalid Argument
by jhs3 (Novice) on Jun 01, 2007 at 19:21 UTC
    Solution Found.
    As I posed as a possibility in my original post - the problem had nothing to do with the perl script. It was a password problem on the NT Server. The 'root' user password was changed. But - where was the password even being referenced?
    Answer: In the NT Services. There is a Service called Remote Shell Service. When the script is run on the Unix system, running a 'remsh' goes through the Remote Shell Service. The Service was started by the 'root' user. The Service does not stop, unless something makes it stop. It had been started with the 'old' 'root' password. I stopped it, restarted it with the 'new' 'root' password and the script on Unix runs perfectly. Again.
    FunkyMonk & cdarke: I appreciate the input. But, as I mentioned in the (admittedly long-winded) writeup - this process has been working for 7 years. The code didn't change. Something outside the code changed, and I finally found that. And, it now works again.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (5)
As of 2016-09-27 05:25 GMT
Find Nodes?
    Voting Booth?
    Extraterrestrials haven't visited the Earth yet because:

    Results (494 votes). Check out past polls.