#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    14
    Rep Power
    0

    Smile UNC file execution


    Hi All

    Im totally new to python and im going crazy.

    I am trying to launch a batch file from the network (UNC path), but it doesnt seem to execute this batch file as this ia one batch that sets the environment for the following batches.

    Kindly help me in this regard.

    Im using the command

    os.system("\\\\servername\\folder\\env.bat")
  2. #2
  3. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,996
    Rep Power
    481
    Please show the command that works as you'd enter it to the DOS prompt. Please show the error messages. Thanks.
    [code]Code tags[/code] are essential for python code and Makefiles!
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    14
    Rep Power
    0
    Hi

    I executed the script by running the cmd python main.py.

    The script main.py consists of just 3 lines of code

    impot os

    os.system("\\\\servername\\dir\\file1.bat")
    os.system("\\\\servername\\dir\\file2.bat")

    Without executing these 2 batch files I cannot proceed to the rest of the coding part.

    The file1.bat is the one that sets an environment for the file2.bat to work.

    So I do not get any error message with file1.bat but the error i get is file2.bat is not recognized as an internal or external command.

    Thanks for the reply.
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    14
    Rep Power
    0
    Hi

    I executed the script by running the cmd "python main.py."

    The script main.py consists of just 3 lines of code

    impot os

    os.system("\\\\servername\\dir\\file1.bat")
    os.system("\\\\servername\\dir\\file2.bat")

    Without executing these 2 batch files I cannot proceed to the rest of the coding part.

    The file1.bat is the one that sets an environment for the file2.bat to work.

    I do not get any error message with file1.bat but the error i get is file2.bat is not recognized as an internal or external command.

    So I'm guessing that the execution of file1.bat has failed.


    Thanks for the reply.
  8. #5
  9. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,996
    Rep Power
    481
    I apologize for my unclear question.

    I meant, what is the command line you use to run file1.bat . Certainly it's not

    A:> \\servername\dir\file1.bat

    Does file1.bat need execute permission? I haven't written a .bat file in at least 3 years.
    [code]Code tags[/code] are essential for python code and Makefiles!
  10. #6
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    14
    Rep Power
    0
    It is by default

    c:\users\dj:> \\servername\dir\file1.bat


    I do have execute permission to run the batch files because i did try and execute the file1.bat and file2.bat manually and it works fine.

    I also did try and map the network path to z:\file1.bat and try the command

    os.system("Z:\\file1.bat")

    But still no luck.

    Thanks

IMN logo majestic logo threadwatch logo seochat tools logo