An example Perl one-liner on my system:my $home='~/bin/MIReNA-2.0'; system("cd $home; ./MIReNA.sh");
In the latest example above, I used exec because I did not care that the program would die immediately after having displayed the content of the directory. I would use system if I wanted the Perl program to do other things after having run the shell command. And if I wanted to retrieve the data in Perl (which is probably the most common use of shelling out calls to the OS), say to format the output of the ls command with line numbers, then I would use backticks instead of exec or system:$ perl -e ' exec "cd ./Matt; ls -l"' total 11756 drwxr-xr-x+ 1 Laurent None 0 27 juin 19:26 appartement -rwxr-xr-x 1 Laurent None 12038144 27 juin 22:27 appartement.tar
$ perl -E ' my @content = `cd ./Matt; ls -l`; print ++$i, ": $_" for +@content' 1: total 11756 2: drwxr-xr-x+ 1 Laurent None 0 27 juin 19:26 appartement 3: -rwxr-xr-x 1 Laurent None 12038144 27 juin 22:27 appartement.tar
In reply to Re: could not get exec and sytem to work
by Laurent_R
in thread could not get exec and sytem to work
by mnam
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |