http://www.perlmonks.org?node_id=1028259


in reply to Re^3: Unable to connect to some SFTP servers using Perl::SFTP
in thread Unable to connect to some SFTP servers using Perl::SFTP

I enabled forks as follows by using system call to create a new terminal to run each ftp/sftp connection in a seperate perl script. It's able to execute but I am having issues when my parameters(@fields) contain bracket. I am not able to pass parameters which contains bracket.
unless (fork()) { system("xterm -T $fields[0] -e \.\/uploader\.pl $index @field +s"); exit(0); }
Error msg
sh: syntax error at line 1: `(' unexpected
After executing the window closes automaticaly. Is there a way to make it halt until the user press a key to exit or so. I tried to have a  <> at the end of the uploader script. But doesn't help

Replies are listed 'Best First'.
Re^5: Unable to connect to some SFTP servers using Perl::SFTP
by skylinedreamer (Novice) on Apr 12, 2013 at 03:03 UTC
    Found a solution for the terminal to wait for user input from http://ubuntuforums.org/showthread.php?t=882185
    system("gnome-terminal -x bash -c './uploader.pl $index @fields; read +-n1'");
    But still I am not sure on how to fix the bracket issue.
      The brackets are being intercepting by the shell. You have to properly quote shell metacharacters... actually, as there are two shells being invoked (the one used by perl to run your command and the one you are calling explicitly), you will have to double quote your arguments.

      If you want to follow that route and need help about quoting I advice you to post a new question.

        Found a fix by using quotemeta(). Did that to all my parameters and its working. Thanks
        for($i = 0; $i <= $#fields; $i++) { $fields[$i] = quotemeta($fields[$i]); }