Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Re: Re: Re: system, pipes, shell, quoting

by superpete (Beadle)
on Nov 13, 2002 at 06:39 UTC ( #212505=note: print w/replies, xml ) Need Help??


in reply to Re: Re: Re: system, pipes, shell, quoting
in thread system, pipes, shell, quoting

Just so you know, my test data really does contain EVERY conceivable character. For testing, the filenames are a random mix of the characters:
chr(rand(128))
except for "/" and "\0"

Replies are listed 'Best First'.
Re:^4 system, pipes, shell, quoting
by graff (Chancellor) on Nov 13, 2002 at 07:22 UTC
    my test data really does contain EVERY conceivable character

    That's swell. So you need to cope with the residue of processes that create files whose names consist of randomly selected byte values? (Why stop at 128?) I hope that your execution path doesn't include directories or programs with such liberal names -- that could be a very awkward system to work with...

    Given such an environment, I'd be inclined to focus on a means to rename files that have troublesome characters in their names -- e.g. using readdir, locate each data file whose name would match /[^-\w\$\@\%\#.,:+~=]/, invent a new name for each such file using only sensible characters, perhaps create a suitable table that documents the original "name" and the newly-assigned name, and rename the file before you do anything else with it. Creating and assigning distinct, usable names is easy. Don't even start to worry about how to run a shell command on file names that contain control characters and whatnot.

    update: If renaming nasty files is not an option (due to permissions or politics), you could use the "symlink()" function instead, creating a nice name for accessing the file without altering the original directory entry. The symlink wouldn't need to be in the same place as the file (could even be on /tmp, and last only as long as needed to run system("long | pipe | command")

      So you need to cope with the residue of processes that create files whose names consist of randomly selected byte values?

      Well, that requirement is for completeness, really. I conjectured that it would not be difficult to deal with (all the "File::" packages can take arbitrary characters). There's probably some really neat 2-line way to do it... i'm hoping Randal Schwartz shows up :-)

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (4)
As of 2021-03-05 03:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My favorite kind of desktop background is:











    Results (109 votes). Check out past polls.

    Notices?