简体   繁体   中英

How can I get the variable that a python file with a path prints when I call that python file from a shell script?

For some reason when I run this in my shell script only $exec_file and $_dir get passed into module_test.py, but neither $filename nor $modified_file get passed.

mod_test=$( /path/module_test.py $modified_file $_dir $filename )

(path is just a normal path that I decided to shorten for the sake of this example) Am I typing this wrong? I am trying to get the output (an integer) of my module_test.py to be put into the variable mod_test.

My variables are:

modified_file = _File
_dir = /path to directory/
file = _File.py

根据您的示例,您需要用引号括$_dir ,因为它包含空格,即:

mod_test=$( /path/module_test.py $modified_file '$_dir' $filename )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM