if ( -x '/path/to/file' ) { # file is executable, run it system('/path/to/file'); } else { # whatever system('/run/something/else'); }