Aks
Aks

Reputation: 5236

Perl exec command failing

I'm trying to execute a shell command via a perl script that looks as follows

 $cmd = 'cat <(ssh -o \"StrictHostKeyChecking no\" dev-adm1 \'sudo cat /etc/httpd/conf/httpd.conf\')';
 exec $cmd;

This is throwing an error

sh: -c: line 0: syntax error near unexpected token `('
sh: -c: line 0: `cat <(ssh -o \"StrictHostKeyChecking no\" dev-adm1 'sudo cat /etc/httpd/conf/httpd.conf')'

The command works directly on the shell but not like this. What am i missing?

Upvotes: 1

Views: 344

Answers (1)

Hachi
Hachi

Reputation: 3289

which shell did you use to test this command?

my first guess is that you used bash or ksh, while sh (used by perl exec) doesn't know the '(' syntax

Upvotes: 3

Related Questions