我知道如何从shell脚本调用我的python脚本。请告诉我如何将Python的输出作为变量收集回shell脚本中?
例如,我有一个shell脚本,它从while循环中调用Python。根据Python输出的值,循环是继续还是退出。
my.sh
x=0
while [ $x -lt 1 ]
do
#Get a value for x from my.py
python ./my.py
done
my.py
if something: x=1
else: x=0
x
另外,我可以得到多个python输出吗?例如,收集x& y的值?
my2.py
if something: x,y=1,1
我使用requests模块在Python中构建了一个web-scraper。它经常读取和写入文本文件。我试着把脚本放在服务器上,让它自动将数据发布到我的网站上。我的理解是,web应用程序每次被访问时都会启动一个新的Python实例,这不是我想要的。我正在尝试运行我的Python脚本的一个实例,然后将数据发布到我的站点上。 我研究了Heroku,但我不知道如何自己使用他们的平台。我有一种预感,AWS可以做这样的事情,但我不知道怎么做。 这是我尝试在服务器上运行的脚本类型: # This is an oversimplification of my web-scraper, but its ba
我有两个python脚本:
#1. getUrl.py # used to collect target urls which takes about 10 mins and used as the input for the next script
#2. monitoring.py # used to monitoring the website.
00 01 * * * /usr/bin/python /ephemeral/monitoring/getUrl.py > /ephemeral/monitoring/input && /usr/bin/python /
我正在运行一个脚本,它将触发一个select查询并将结果插入到一个表中。
select查询是
select distinct a.child child_id, a.parent parent_id from cat a, par b WHERE a.child=b.catentid and b.catenttype_id='Product' and a.reltype_id='PRODUCT_ITEM'
并插入到表中,该表创建为
create table TI_CAT_0 ( child_id NUMBER not null,parent_id NUMBER
我正在亚马逊EMR实现之上运行一个python脚本。因此,从主脚本中,我得到了条目的相似性。在事后处理步骤中,我希望将这个输出分割为每个项目的单独的S3桶,因此每个项目-桶包含一个类似于它的项目列表。为了实现这一点,我希望在善后步骤的减缩函数中使用Amazons boto python库。
如何将外部(python)库导入hadoop,以便在用python编写的缩减步骤中使用?可以在Hadoop环境中以这种方式访问S3吗?
谢谢你,托马斯
目标:
我要把每个国家的总数加起来。在下面的例子中。总数应该是200。但很明显,我得到了600美元。基本上,我需要每个客户id的总列中的值,并按国家分列。
形势:
我的模型有以下几个维度
+--------------+-------------+----------+-------------+------------------+
| country name | customer id | order id | Price_total | price before tax |
+--------------+-------------+----------+-------------+-