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

Howdie呢,

获取此脚本在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 

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

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

test.sh:第4行:awk:command not found

test.sh:第7行:[::整数expression式预期

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

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

我错过了什么吗?

我想到了。

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

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

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

从C:\ cygwin64 \ bin开始