Why does Perl system () corrupt a redirected path?

I have the following command in a perl script that I use:

system ("mycommand /home/tahoar/ไมโคร_tm-อังกฤษ-ไทย/giza.อังกฤษ-ไทย/อังกฤษ-ไทย.A3.final.part*>/home/tahoar/ไมโคร_tm-อังกฤษ-ไทย/giza.อังกฤษ-ไทย/อังกฤษ-ไทย.A3.final") 

This command failed:

 sh: cannot create /home/tahoar/ไมโคร_tm-อัง  ฤษ-ไทย/giza.อัง  ฤษ-ไทย/อัง  ฤษ-ไทย.A3.final: Directory nonexistent 

My troubleshooting determined that "mycommand" was never executed. This also happens with many other commands (mycommand1, mycommand2, etc.). The command line is UTF-8. The intended output path already exists. I set LC_ALL = C for other purposes. The same command is executed correctly with a Latin character in the path.

Why is the path to the redirected path damaged?

+4
source share
1 answer

I tried for sure this command. If the directory is missing, I get exactly the same error. After the corresponding mkdir everything seems fine.

The command does not run in your case, since perl launches sh, which first tries to configure your redirects and then runs your command related to prepared redirects. - In your case, sh cannot prepare redirects and therefore cannot run a real command.

As you say, “the output path already exists”, but perl says that “Directory nonexistent” both of you seem to be talking about different paths.

Try mkdir or ls output path from inside perl. Then you can see what happens.

+2
source

All Articles