简体   繁体   English

在命令提示符下使用 for 循环执行 python3 脚本

[英]Execute python3 script using for loop in command prompt

Folder stucture->文件夹结构->

在此处输入图像描述

Problem stmt- I am trying to run the setup files from command prompt.问题 stmt - 我正在尝试从命令提示符运行安装文件。

Steps I m following-我正在遵循的步骤-

  1. cd Parent光盘父
  2. set pkgs=Child1,Child2,Child3设置 pkgs=Child1,Child2,Child3
  3. for %P in (%pkgs%) do cd %P && python setup.py && cd..对于 %P in (%pkgs%) 执行 cd %P && python setup.py && cd..

Expected output-预期产出-

It should run the files.它应该运行文件。

Current output- It prints the lines as is.当前输出 - 它按原样打印行。

cd Child1 && python setup.py && cd.. cd Child1 && python setup.py && cd..

cd Child2 && python setup.py && cd.. cd Child2 && python setup.py && cd..

cd Child3 && python setup.py && cd.. cd Child3 && python setup.py && cd..

Use sh,使用 sh,

cd ......./Child1
python3 setup.py &
cd ......./Child2
python3 setup.py &
cd ......./Child3
python3 setup.py &

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从python中的命令提示符执行脚本 - How execute script from command prompt in python 无法在 python3.8.3 中“导入 win32com.shell.shell”以使用 python3 执行管理员命令提示符命令 - Not able to “import win32com.shell.shell” in python3.8.3 to execute admin command prompt commands using python3 使用鼠标右键>>在此处命令提示符后执行脚本时,Python无法正常工作 - Python doesn't work properly when I execute a script after using Right Click >> Command Prompt Here 通过windows命令提示符循环执行python程序 - execute python programme in loop through windows command prompt 我们如何从 Python 执行下面的命令提示符脚本 - How we can execute below Command Prompt Script from the Python 如何在Windows命令提示符下执行sql Python脚本? - How to execute sql Python script in Windows command Prompt? 使用python脚本在命令提示符下运行命令 - Run commands in command prompt using python script 如何在循环中使用SCP命令时转到用户名提示(Python脚本) - How to go to username prompt while using SCP command in a loop(Python script) 如何使用 python 命令执行 python 脚本 - How to execute python script using python command 使用子进程在python中执行linux命令,然后获取结果提示 - Using subprocess to execute a linux command in python and then grab the resulting prompt
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM