Beefy Boxes and Bandwidth Generously Provided by pair Networks Cowboy Neal with Hat
laziness, impatience, and hubris
 
PerlMonks  

Re: unix mv command

by japhy (Canon)
on Jun 15, 2007 at 11:04 UTC ( #621437=note: print w/ replies, xml ) Need Help??


in reply to unix mv command

I have no idea what's in those variables, so I can't really tell you. Perhaps $different_path has spaces in it?


Jeff japhy Pinyan, P.L., P.M., P.O.D, X.S.: Perl, regex, and perl hacker
How can we ever be the sold short or the cheated, we who for every service have long ago been overpaid? ~~ Meister Eckhart


Comment on Re: unix mv command
Re^2: unix mv command
by xmanamit (Initiate) on Jun 15, 2007 at 12:09 UTC
    I have tested the paths, and they are fine as I used the perl mv command using File::copy module with the same variables. But can't understand why this doesn't work.
      If you let us see the paths, then we may be able to explain it.

      Clint

      I have tested the paths, and they are fine as I used the perl mv command using File::copy module with the same variables. But can't understand why this doesn't work.

      Non sequitur. Suppose that $from='foo' and $to='bar baz'. If you pass these arguments to F::C's mv(), then it will try to move the the file named foo to that called bar baz - with a space in it. If you do

      system("mv $from $to");

      as in your first post, a shell will be started which in turn will call the external mv program with the three cmd line arguments foo, bar and baz. (Well, upon a closer look to the docs it seems that it will call the shell only if there are shell metacharacters, but the final result won't change.) This may not be your case, but it serves as an instructive example. Alternatively use the LIST form of system, which will avoid the shell in any case and more likely do the Right Thing™ - and check its return value:

      0 == system 'mv', $from, $to or warn "Something wrong: $?\n";

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://621437]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (8)
As of 2014-04-19 01:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (475 votes), past polls