Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: How to change Current Shell's Pwd ?

by Ytrew (Pilgrim)
on Feb 07, 2005 at 07:04 UTC ( [id://428587]=note: print w/replies, xml ) Need Help??


in reply to How to change Current Shell's Pwd ?

When you use backticks or the system() function, you're starting up a command shell for your operating system, changing the current directory of the command shell, then exiting the command shell and returning to perl. Perl's notion of the current directory doesn't change.

If you want the present working directory that perl uses to change, you need to use the chdir() function.

In your example, you'ld want something like:

$status = chdir("/home/test"); # next, check status to see if we successfuly changed directory. die("Can't change to directory /home/test:$!") unless($status);

You might want to double check the documentation to see what the return value of chdir() is like, but I think that's right: then again, I'm typing from memory at 2:00 am. ;-)

Hope that helps,
--
Ytrew

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (8)
As of 2024-04-18 06:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found