III am writing a Perl script that will need to SSH out to numerous remote servers to perform some gzipping of log files. In the following line, I keep receiving this error and am struggling to determine what's causing this. The error I'm getting is;
bash: -c: line 0: syntax error near unexpected token `('
bash: -c: line 0: `cd /appdata/log/cdmbl/logs/; echo cd /appdata/log/cdmbl/logs/; find . -type f ( -iname '*' ! -iname '*.gz' ) -mmin +1440 ;; exit 0'
And of course, as you can tell by the error, the line I am trying to write is;
my $id = qx{ssh -q $cur_host "cd $log_path; echo cd $log_path; find . -type f \( -iname '*' ! -iname '*.gz' \) -mmin +1440 \;; exit 0"};
Am I overlooking something here that is causing the unexpected token '(' issue I am receiving?
NOTE: I removed the -exec from find just so I could see if I can get past this issue first.
Thanks.
You need to backslash the parentheses for the shell. Using single backslash in double quotes is not enough, Perl removes the backslash. Use double backslash \\(
.