Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Perl script error

by sellinios (Initiate)
on Apr 21, 2016 at 10:39 UTC ( [id://1161076]=perlquestion: print w/replies, xml ) Need Help??

sellinios has asked for the wisdom of the Perl Monks concerning the following question:

Hi I am getting the following errors in perl script after the restructure of folder tree. Could you please help me ?
rm /home/meteo/Build_WRF/DATA/WRF/greece-9km/2016042112/wps/FILE:* rm: cannot remove ‘/home/meteo/Build_WRF/DATA/WRF/greece-9km/201604211 +2/wps/FILE:*’: No such file or directory system rm /home/meteo/Build_WRF/DATA/WRF/greece-9km/2016042112/wps/FIL +E:* failed: 256 at /home/meteo/Build_WRF/SCRI PTS/autorun.WRF.v3.pl line 116. Warning: something's wrong at ./autorun.v3.pl line 52. Name "main::fname" used only once: possible typo at /home/meteo/Build_ +WRF/SCRIPTS/plot.maps.v2.pl line 115. Name "main::wpsdir" used only once: possible typo at /home/meteo/Build +_WRF/SCRIPTS/plot.maps.v2.pl line 30. Name "main::wrfdir" used only once: possible typo at /home/meteo/Build +_WRF/SCRIPTS/plot.maps.v2.pl line 31. Name "main::wrfdmdir" used only once: possible typo at /home/meteo/Bui +ld_WRF/SCRIPTS/plot.maps.v2.pl line 32. Name "main::postdir" used only once: possible typo at /home/meteo/Buil +d_WRF/SCRIPTS/plot.maps.v2.pl line 33. Name "main::gfsdir" used only once: possible typo at /home/meteo/Build +_WRF/SCRIPTS/plot.maps.v2.pl line 35. Name "main::regdir" used only once: possible typo at /home/meteo/Build +_WRF/SCRIPTS/plot.maps.v2.pl line 29. No such file or directory at /home/meteo/Build_WRF/SCRIPTS/plot.maps.v +2.pl line 46. Warning: something's wrong at ./autorun.v3.pl line 54. STOPElapsed time : 16m

Replies are listed 'Best First'.
Re: Perl script error
by golux (Chaplain) on Apr 22, 2016 at 04:58 UTC
    Hi sellinios,

    As talexb said, you really need to show some code for us to see where you're having problems.

    That said, it's a fair bet the first error you've got:

    rm: cannot remove ‘/home/meteo/Build_WRF/DATA/WRF/greece-9km/201604211 +2/wps/FILE:*’: No such file or directory

    happened because the code was trying to remove all files a bunch of files that didn't exist. You're probably running on Linux because of the /home dir, and the "rm" command. On my Linux system, the same error (and the same exit status, 256) happen with this test script:

    #!/usr/bin/perl -w use strict; use warnings; system("rm dir/FILE:*"); my $err = $?; print "Error is $err\n"; # Output is: rm: cannot remove ‘dir/FILE:*’: No such file or directory Error is 256

    If I change that script to use glob and unlink (better because they're Perl builtin functions, hence don't rely on calling the shell which is a more expensive operation):

    #!/usr/bin/perl -w use strict; use warnings; foreach my $file (glob("dir/FILE:*")) { if (!unlink($file)) { print "Warning: failed to remove file '$file' ($!)\n"; } }

    That way, if there aren't any files, it won't fail due to shell not finding any matches.

    It's interesting to note that the shell will always do its own globbing before passing results to the command (rm in your case) -- to verify this, you can try "echo *" and see all your files/dirs the way they'd look prior to passing them to any Unix command ("ls" for example).

    And unlike Perl, the shell will throw an error if a wildcard such as "*" or "?" fails to find any matching files.

    say  substr+lc crypt(qw $i3 SI$),4,5
      I have gave you a link with my git. Did you see that?

        Thanks for your reply -- and welcome to The Monastery.

        Here's the way this site works: people post questions about Perl on the site, and other people answer them.

        Sometimes the questions spark an interesting discussion about computer science, algorithms, operating systems -- it can be quite fascinating. Sometimes people are directed to the excellent documentation that's already available (I've even contributed to the docs myself -- it's awesome to see your own name in Perl's credits).

        And sometimes people have a question about their code. When the code isn't provided directly, it's a bit of a thought experiment to figure out what might be wrong. The whole thing's a black box. This can be entertaining, but it's most likely unsatisfying for the developer trying to solve their problem. So we encourage the posting of the code in question directly on this site, rather than provided by a link off-site.

        Why? Because sometimes the discussion we have today can be useful in a year's time. And in a year, the file that you've put on bitbucket.org (or whatever) could be gone, leaving a bit of a hole in the discussion.

        In addition, if you can pare down your example to the barest of necessities to show the problem (and, of course, use strict and use warnings), that will make it easy for us to diagnose the problem and provide a solution.

        And this is a somewhat long-winded post, but I'm attempting to forestall the inevitable back-and-forth that happens when a new member arrives.

        Post something useful, read, learn, listen, become a better developer. And (this is my favorite Larry Wall quote), ".. have the appropriate amount of fun."

        Alex / talexb / Toronto

        Thanks PJ. We owe you so much. Groklaw -- RIP -- 2003 to 2013.

      https://bitbucket.org/lefteris_papadopoulos/meteo/src
Re: Perl script error
by talexb (Chancellor) on Apr 21, 2016 at 14:33 UTC
      I am getting the following errors in perl script after the restructure of folder tree ..

    Without any information on the script that you're running, it seems pretty clear that your re-structuring has caused the problem. I'd address that by reversing the re-structuring you've done.

    Alex / talexb / Toronto

    Thanks PJ. We owe you so much. Groklaw -- RIP -- 2003 to 2013.

Re: Perl script error
by sellinios (Initiate) on Apr 21, 2016 at 15:38 UTC
    hi, is it possible I give access on my git and somebody review the error ?

      If it's a public git repo, that should be simple. You can also make people collaborators to a repo.

      Alex / talexb / Toronto

      Thanks PJ. We owe you so much. Groklaw -- RIP -- 2003 to 2013.

        Yes sure, I have give you an address, I can provide you also access for corrections.
      What I am running is ./autorun.v3.pl here. https://bitbucket.org/lefteris_papadopoulos/meteo/src/e706a3fa732e03eee34df55253864b1595adb66c/Build_WRF/SCRIPTS/?at=master
        Anybody?

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (2)
As of 2024-04-20 04:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found