Python Forum
Running script with subprocess in another directory
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Running script with subprocess in another directory
#1
Hi,

I'm trying to run an executable script (thanks to chmod +x) but located in another directory; whatever I do, it is running in the current directory i.e. where the python file is: what am i missing? I've chosen suprocess.Popen +wait() to be sure all the script has been run prior doing anything else.

Thanks for your comments and advices

Paul
MyScrip = 'Script.sh' # chmod +x Script.sh
RunScrip = subprocess.Popen(['sh', NewPath + '/' + MyScrip ])
RunScrip.wait()
Reply
#2
Finally the following seems to work adding cwd

RunScrip = subprocess.Popen(['sh', MyScrip ], cwd = NewPath)
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  No Internet connection when running a Python script basil_555 8 579 Mar-11-2024, 11:02 AM
Last Post: snippsat
Question Running Python script through Task Scheduler? Winfried 8 468 Mar-10-2024, 07:24 PM
Last Post: Winfried
  Help Running Python Script in Mac OS emojistickers 0 339 Nov-20-2023, 01:58 PM
Last Post: emojistickers
  Trying to make a board with turtle, nothing happens when running script Quascia 3 658 Nov-01-2023, 03:11 PM
Last Post: deanhystad
  Python script running under windows over nssm.exe JaroslavZ 0 704 May-12-2023, 09:22 AM
Last Post: JaroslavZ
  python keeps opening script directory Tyrel 5 2,997 Aug-06-2021, 10:43 PM
Last Post: snippsat
  Running script on multiple files Afrodizzyjack 1 2,508 May-14-2021, 10:49 PM
Last Post: Yoriz
  problem with sphinx and file directory in script kiyoshi7 0 2,285 Mar-11-2021, 03:52 PM
Last Post: kiyoshi7
  Error when running script on startup in Linux NoahTheNerd 0 1,954 Mar-07-2021, 04:54 PM
Last Post: NoahTheNerd
  Refresh data in python script while running in Terminal frankenchrist 4 7,249 Feb-03-2021, 09:54 AM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020