T.S. Ravi Shankar wrote:

Hi all :

Could anyone tell me how I could move between the directories ( or
change the present working directory ) with any perl command ??

I have tried these   system '/bin/cd $HOME'; ,   chdir '$HOME'; ,
exec 'cd $HOME';

After I execute the perl code, the PWD still remains unchanged.


This is roughly how shell executes commands, 1) fork a child process 2) exec the command in the child

Your option 1) system '/bin/cd $HOME'
This will create a sub shell from within your perl script and change it's current working directory.
Result: The cwd of your perl script process remains the same and so does it's parent's


Your option 2) chdir '$HOME'
The single quote will not expand the scalar $HOME, I guess this call should have failed.
chdir $HOME is what you are looking for.
Result: This will change the cwd of your perl script process not it's parent's


Your option 3) exec 'cd $HOME'
This will overlay you perl process' image, but the parent's cwd will still not change.


cd is a shell built-in. It is not an external command. We can help you better, if you explain why you are doing this


If the above ways are incorrect, please direct me to the correct.


Thanks,
Ravi











-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to