Command doesn't execute

Hi All.

Little mystery here. I've been teaching myself perl, and I want to execute regular linux / unix commands i.e. cd .. , cd /etc and have been using the command(s)

execute ("cd ..");
or
system ("cd ..");

I don't get any error messages, even when I do a debug, but for some reason even this doesn't work.

Here is the super-simple code I am using:

What am I doing wrong?

Regards

There is a problem with these lines:

What do you expect the lines to do? What output do you anticipate, and what output did you receive?

We cannot guess what a faulty command is intended to do.

Hi.

The commands are quite simply expected, by myself, to change the directory up one level, then change the directory to the /etc directory.

I get no results from either command shown by a changed directory.

This code:

gives this result

The directory does not change...

Regards

exec will replace the current process with the command which you executed.And if a shell script changes the working directory,the parent shell(process) won't be affected.

Ok.

So if that is the case, then how do I execute multiple commands in a row?

:confused:

Regards

Every command shown in your script can be achieved with a simple Shell script and does not need Perl. No sure what you want to achieve here. Maybe you need to sort out the "cd" commands in Shell, then call the Perl script from the Shell script?

To answer you question properly, please look at the Perl "chdir" command.
http://www.perlhowto.com/system