[torqueusers] no spaces in directory names

Pete Wyckoff pw at osc.edu
Fri Feb 8 08:06:19 MST 2008


garrick at usc.edu wrote on Thu, 07 Feb 2008 14:21 -0800:
> On Thu, Feb 07, 2008 at 10:40:25AM -0500, Pete Wyckoff alleged:
> > Sigh.  That's what we already told the user who triggered this.  But
> > it is rather unfortunate.  POSIX clearly tells us that filenames may
> > include any character except / and \0.  A shame we have to break
> > this in the batch queueing world.
> > 
> > This getcwd() case seemed like a very understandable case of the
> > user not doing anything blatantly tricky.  But support for wildcards
> > and such is getting in the way of having that just work?
> 
> I know.  I'm trying hard to figure out how to make everything work.
> 
> As I said, I think I have everything working except scp.

Okay, thanks for looking at this.  I went back and read the archives
to study Konrad's mail.  He has expressed the key idea that one
extra level of quoting is required to avoid shell expansion on the
far side.

Thus the moral equivalent of:

    args[0] = "scp";
    args[1] = "./foo";
    args[2] = "'" + "hpc-admin:/home/rcf-00/garrick/5000 atoms/" + "'";
    args[3] = NULL;
    execvp("scp", args);

Where the two extra quotes in args[2] is all that is needed, to a
first approximation.

But if you are starting scp through a shell, you'll need a
second level of quoting:

    system("scp " + "'" + "./foo" + "'" + " " +
           "\''" + "hpc-admin:/home/rcf-00/garrick/5000 atoms/" + "'\'");

The outer \' get passed through as single quotes to the far side,
where they protect the path.  The inner '' keep the local shell from
molesting the path.  Recommend you don't use system for this extra
confusion.

This scheme breaks in one case, when the string itself contains
single quote characters.  For that it is necessary to rewrite the
remote path.  But not for each space or double-quote or others.

Each single tick in the far-side string (the hpc-admin part) should
be replaced with the six-character series:  '\\\''.  To do this in C
you'll need more backslashes too.  If you have some mpiexec source
handy, take a look at growstr.c in the growstr_append() function.  I
had to suffer through this at some point in the past.

(If you are using system, you will need to do convert single ticks
in the local part of the argument too, but just ' -> '\''.)

But I'm probably missing some subtlety of the torque-specific
problem here.

		-- Pete


More information about the torqueusers mailing list