xiaoming728

xiaoming728

Navicat 17 for mac 无限14天试用

2024-07-05
Navicat 17 for mac 无限14天试用

1.官网下载Navicat 17

https://www.navicat.com.cn/download/direct-download?product=navicat170_premium_cs.dmg&location=1

2.创建navicat.sh脚本

#!/bin/bash

set -e

file=$(defaults read /Applications/Navicat\ Premium.app/Contents/Info.plist)

regex="CFBundleShortVersionString = \"([^\.]+)"
[[ $file =~ $regex ]]

version=${BASH_REMATCH[1]}

echo "Detected Navicat Premium version $version"

case $version in
    "17")
        file=~/Library/Preferences/com.navicat.NavicatPremium.plist
        ;;
    "16")
        file=~/Library/Preferences/com.navicat.NavicatPremium.plist
        ;;
    *)
        echo "Version '$version' not handled"
        exit 1
       ;;
esac

echo -n "Reseting trial time..."

regex="([0-9A-Z]{32}) = "
[[ $(defaults read $file) =~ $regex ]]

hash=${BASH_REMATCH[1]}

if [ ! -z $hash ]; then
    defaults delete $file $hash
fi

regex="\.([0-9A-Z]{32})"
[[ $(ls -a ~/Library/Application\ Support/PremiumSoft\ CyberTech/Navicat\ CC/Navicat\ Premium/ | grep '^\.') =~ $regex ]]

hash2=${BASH_REMATCH[1]}

if [ ! -z $hash2 ]; then
    rm ~/Library/Application\ Support/PremiumSoft\ CyberTech/Navicat\ CC/Navicat\ Premium/.$hash2
fi

echo " Done"

3.将脚本添加到定时任务,时间自定义调节

打开终端(Terminal)编辑crontab文件,输入以下命令:

crontab -e

在打开的crontab编辑器中,添加以下内容:

40 9 * * * /Users/liuchunming/file/navicat.sh > /Users/liuchunming/file/navicat.log 2>&1 &

这条命令的含义是每天早上9点40分执行navicat.sh脚本,并将输出重定向到navicat.log文件中。如果希望在后台运行,请在命令末尾加上&符号。