I'm writing a program to transfer some logs to another machine for further analysis on that machine (this is not questionable).

Now the problem is that the logs' filenames contain ehm... a '>' sign. Now, up to this very moment we had not had any substantial problem with this, apart that it is a PITA whenever one has to manually peek into one of those logs and systematically forgets to quote them (because he's using C&P from the output of some other program).

But now a much more serious problem arose, probably due to the fact that I'm using Net::SCP to transfer the files and that this module is only a wrapper around scp. Please note that I say so because I succeed in transferring files with "normal" names whereas I can't get around those damned logs either using them literally or (adopting the dirty workaround of) quoting that '>'.

The relevant portions of code are:

my $scp=Net::SCP->new( { host => 'the_real_host', user => 'the_real_user', interactive => 0, cwd => '/path/to/somewhere' } ); # ... (my $quoted=$_) =~ s/>/\\>/; if ( $scp->put($quoted) ) { # if ( $scp->put($_) ) { # etc
Do you have any suggestion about alternative {modules,strategies} to use? Also, it's not something I ask for, generally, but could you supply some ready-made minimal examples?

PS: desperately looking for a workaround to this embarassing situation I'm thinking of copying them to a temporary, "human-named" file before transferring them.

PS2: we have already cursed the author of the logs-writing program and its behaviour will certainly be fixed in the future, but unfortunately it's not doable soon...

Thank you in advance!

Edit by castaway - changed title from 'Q: re scp'


In reply to Escaping special characters in filename for Net::SCP by blazar

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.