locked
Working directory not fully "inherited" by task batch-file commands? RRS feed

  • Question

  • Hello all, If I set the working directory to \\server\share, and submit a job with a single task which is a batch file with two commands in it: echo “testing” > out del out It will create the file “out” under \\server\share, but fails on the “del” saying “The file name, directory name, or volume label syntax is incorrect.” If I change the line “del out” to “del \\server\share\out” it succeeds. Whatever I set “Working directory” to, or if I let it default to my profile on the node, it creates “out”, but the “del” never finds it unless I hard-code it. Why must I hard-code the absolute UNC path? Note if I login manually to the node and “cd \\server\share; cmd.exe /c \\server\share\file.bat” it works fine. How can I use relative paths for all files in a task’s batch file? It seems working directory isn’t being used for every command (like del), but only for some (like echo + redirect). This is running 2003 Compute Cluster, Job Manager 1.0.067614. Thanks for any tips.
    Tuesday, September 8, 2009 6:42 PM

Answers

  • Interesting question!  You are hitting an extension of the the famous "cmd.exe doesn't allow UNC working directories" issue.  Unfortunately that has been a knonw issue for users and will probably never change :(  Basically once the working directory is set to a UNC path, some of the built in cmd.exe primitives (like del) won't work.  You don't need a batch script to do this; try creating a single task job that runs del on a UNC path and you will hit the same problem (job submit /workdir:\\server\share del somefile.txt).

    In addition to the workaround that you found (just put the whole path to whatever you want to delete), you can write a more robust script using an environment variable.  For example, if your task was converted from "del somefile.txt" to "del %CCP_WORKDIR%\somefile.txt" it should do the right thing and delete somefile.txt form the task's working directory.  There are many other solutions which are possible as well.

    I'm sorry I don't have better news.

    Thanks!
    Josh
    -Josh
    Tuesday, September 8, 2009 11:15 PM
    Moderator

All replies

  • You could use a batch file test.bat with:
    echo "testing" > out
    del out
    in it.

    I assume this would work.

    Tuesday, September 8, 2009 8:25 PM
  • Interesting question!  You are hitting an extension of the the famous "cmd.exe doesn't allow UNC working directories" issue.  Unfortunately that has been a knonw issue for users and will probably never change :(  Basically once the working directory is set to a UNC path, some of the built in cmd.exe primitives (like del) won't work.  You don't need a batch script to do this; try creating a single task job that runs del on a UNC path and you will hit the same problem (job submit /workdir:\\server\share del somefile.txt).

    In addition to the workaround that you found (just put the whole path to whatever you want to delete), you can write a more robust script using an environment variable.  For example, if your task was converted from "del somefile.txt" to "del %CCP_WORKDIR%\somefile.txt" it should do the right thing and delete somefile.txt form the task's working directory.  There are many other solutions which are possible as well.

    I'm sorry I don't have better news.

    Thanks!
    Josh
    -Josh
    Tuesday, September 8, 2009 11:15 PM
    Moderator
  • Thanks Josh, I appreciate the feedback (although too bad about cmd.exe).
    Wednesday, September 9, 2009 11:34 AM