Cgywin .sh文件作为Windows任务计划程序运行

Jim*_*mmy 2 windows shell cygwin

怎么做,

在使用此shell脚本在Windows任务计划程序中运行时遇到问题.

#!/bin/bash
# Script to ping the VPN server for testing

RESULT=$(ping 192.168.1.252 | grep "Lost" | awk {' print $10 '})
LOG=/home/admin/results.txt

if [ "$RESULT" -gt 0 ];then

    echo "VPN 192.168.1.252 NOT pinging" >> $LOG
else

echo "VPN Online"

fi
Run Code Online (Sandbox Code Playgroud)

当我在cygwin中运行它时,它运行没有问题,但是当我尝试从命令提示符运行它时,我得到以下内容:

C:\ cygwin64\bin> bash test.sh test.sh:第4行:找不到grep:命令

test.sh:第4行:awk:找不到命令

test.sh:第7行:[::预期的整数表达式

我的问题是,如何让它与bash一起运行,以便它实际上知道grep和awk命令?

在Windows Scheduler中,我有动作:启动程序详细信息:C:\ cygwin64\bin\bash.exe参数:test.sh开始于:C:\ cygwin64\bin

我错过了什么吗?

Jim*_*mmy 6

我想到了.

在Windows任务计划程序中,我必须通过:

程序/脚本:C:\ cygwin64\bin\bash.exe

添加参数:-c -l test.sh

开始于:C:\ cygwin64\bin