A cleaned up copy of what you posted:
#!/usr/bin/perl use strict; use warnings; my @cmd = ('/sbin/route'); push @cmd, 'add'; push @cmd, 'default'; push @cmd, 'gw', push @cmd, '172.16.0.200', push @cmd, 'dev'; push @cmd, 'enxb827eb95400d'; system(@cmd);
some lines end with commas when they should be semicolons:
#!/usr/bin/perl use strict; use warnings; my @cmd = ('/sbin/route'); push @cmd, 'add'; push @cmd, 'default'; push @cmd, 'gw'; push @cmd, '172.16.0.200'; push @cmd, 'dev'; push @cmd, 'enxb827eb95400d'; system(@cmd);
If in doubt, print what your variables contain. Tutorials->PerlMonks for the Absolute Beginner/Basic debugging checklist.
In reply to Re: How to execute a linux system command with perl?
by marto
in thread How to execute a linux system command with perl?
by introdev
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |