我是在 Linux (Lubuntu) 上编写脚本的新手,但我想制作一个脚本,仅当我的笔记本电脑连接到我的家庭 wifi 时才运行 cron 作业。
这可能吗?
我想,我可以用 iwconfig 做一些事情,然后用 grep 从那里拉出 ESSID?
到目前为止,我试过这个,它似乎工作:
#!/bin/bash
# CRON, connected to specific WIFI
clear
netid=HOFF216
if iwconfig | grep $netid
then
clear
echo "True, we are connected to $netid"
rsync ...........
else
clear
echo "False, we are not connected to $netid"
fi
Run Code Online (Sandbox Code Playgroud)