Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^6: Getting information about a remote file via SSH: how to escape the filename

by salva (Canon)
on Jun 28, 2013 at 08:13 UTC ( [id://1041175]=note: print w/replies, xml ) Need Help??


in reply to Re^5: Getting information about a remote file via SSH: how to escape the filename
in thread Getting information about a remote file via SSH: how to escape the filename

Suggestions on how to stay safe are very welcome

Avoid the shell as much as you can (i.e. using system $cmd, @args instead of system "$cms @args").

Otherwise, quote your data properly. For instance, for POSIX shells I use the following sub to quote commands and arguments:

my $glob_class = '*?\\[\\],{}:!^~'; sub quote { shift; my $quoted = join '', map { ( m|\A'\z| ? "\\'" : m|\A'| ? "\"$_\"" : m|\A[$noquote_class]+\z|o ? $_ : "'$_'" ) } split /('+)/, $_[0]; length $quoted ? $quoted : "''"; }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1041175]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2024-04-25 16:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found