Shell脚本从python程序获取输入 [英] shell script taking input from python program

查看:89
本文介绍了Shell脚本从python程序获取输入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个运行脚本的shell脚本,该程序具有自己的参数:

I have a shell script which runs a python program which has its own parameters:

#!/bin/bash
python blah.py var1 var2
./run key

我需要找到一种从python程序中检索密钥内容的方法.我试过只是让python程序返回值,然后做:

I need to find a way to retrieve the contents of key from the python program. I have tried just making the python program return the value, and then doing :

key=python blah.py var1 var2

在我的shell脚本中,但这没有用,因为它指出密钥在函数外部".

in my shell script, but that didn't work because it stated key was "outside the function".

预先感谢

推荐答案

使用此

key=`python blah.py var1 var2`
./run $key

这篇关于Shell脚本从python程序获取输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆