Unfortunately, I don't have a system where I can test at the moment, but here are some things I'd try:
- Split the command into a list, e.g. my @cmd = ('C:/Windows/System32/OpenSSH/scp', $src_file, 'vinothg@'.$server.':'.$target_path );
- Use either IPC::System::Simple's capturex (comes preinstalled with Strawberry Perl), as in: use IPC::System::Simple qw/capturex/; my $output = capturex(@cmd);
- Or, use Win32::ShellQuote's quote_system_string, as in: use Win32::ShellQuote qw/quote_system_string/; my $cmd = quote_system_string(@cmd); my $output = qx/$cmd/;
- In terms of error handling, the only case that indicates success is when $? is zero, so you shouldn't be checking $status the way you are, you should be checking if ( $? != 0 ). Update: Note that an advantage of IPC::System::Simple is that it does the error handling for you.
- Although I don't think this is the issue, try saying scp.exe instead of just scp. Also, do try backslashes in the command one more time, as in my @cmd = ('C:\\Windows\\System32\\OpenSSH\\scp.exe', ...