首页 > 解决方案 > Airflow - BashOperator - 运行 2 个 CLI 命令时出错

问题描述

我正在使用 Ubuntu 20.04 和 Airflow 2.0.1。

我在 DAG 中有 BashOperator 任务,如下所示:

proxy_update_getProxies = BashOperator(
    task_id='proxy_update_getProxies',
    bash_command="scripts/proxies-update-get.sh",
    dag=dag)

scripts文件夹在dag文件夹中,因此根据文档,应该可以像这样运行它。

proxies-update-get.sh脚本包含 2 行:

proxy-lists updateGeoIpData --license-key Y00qKC2A9ZoWVXJW
proxy-lists getProxies --protocols="https" --output-format="txt" --output-file="httpsproxies.txt"

proxy-listsnmp可以使用 CLI 中的这两个命令运行以更新和获取代理列表的包。脚本在任何文件夹中都可以正常工作,因此$PATH应该没有问题,但我收到此错误:

can't open file 'proxy-lists': [Errno 2] No such file or directory

我究竟做错了什么?

标签: pythonbashnpmairflowdirected-acyclic-graphs

解决方案


谢谢@00@PeterRing

我刚刚在我的 bash 脚本中使用了节点 CLI 脚本的完整路径,它运行良好:

/home/username/.nvm/versions/node/v14.16.0/lib/node_modules/proxy-lists/cli.js updateGeoIpData --license-key hshshhshshshsh
/home/username/.nvm/versions/node/v14.16.0/lib/node_modules/proxy-lists/cli.js getProxies --protocols="https" --output-format="txt" --output-file="/home/username/airflow/dags/scripts/httpsproxies.txt"

推荐阅读