If you want to change the working directory, use chdir. Using system, even if it worked, would just change it in the child process, which would do you no good. | [reply] |
ysth is correct, using cd will only change the child process, regardless of Cygwin. However, on the assumption that you are using another command which follows (you don't actually say what you are trying to do) then the following works on Cygwin:
system('sh -c "cd ..;ls"');
This invokes the Bourne shell to execute its built-in cd command.
update: 'which cd' gives a similar message on bash and ksh on Linux ('no cd in ...') because cd is a shell built-in. Try 'type cd' instead'
If all you want to do is cat(1) there are very easy ways of doing that in Perl without invoking another program. | [reply] [d/l] |
system('cd ..;ls');
| [reply] [d/l] [select] |
| [reply] |
| [reply] |
Hi aquarium, I have been using forward slashes and double quotes, however the problem seems to be the fact that Perl on cygwin cannot find the "cd" command. In fact if you do a "which cd" from the command line in Cygwin, you get the result "cd: Command not found", whereas this works for commands like "mkdir". Apparently the cd command from system in cygwin uses the Windows cd and this is the source of the problem I'm experiencing.
| [reply] |
Thanks a lot for all your useful comments guys.
Regards,
Thunderbird
| [reply] |