当将新文件添加到Google云存储分区时,我想运行bash脚本。现在,将文件添加到gcs时,我可以运行python脚本。我尝试从python脚本中调用bash脚本,但在shell或日志中看不到任何输出。
这是我的函数main.py,已订阅gcs finalize事件
import subprocess
# [START functions_helloworld_storage_generic]
def hello_gcs_generic(data, context):
subprocess.call("alert.sh", shell=True)
"""Background Cloud Function to be triggered by Cloud Storage.
This generic function logs relevant data when a file is changed.
Args:
data (dict): The Cloud Functions event payload.
context (google.cloud.functions.Context): Metadata of triggering event.
Returns:
None; the output is written to Stackdriver Logging
"""
print('Event ID: {}'.format(context.event_id))
print('Event type: {}'.format(context.event_type))
这里是alert.sh bash脚本
echo "FILE ADDED"