shell
shell学习

How to decode cmd output correctly?

ProcessStartInfo startInfo = new ProcessStartInfo("CMD.exe");
startInfo.Arguments = "/c " + URL;
Process p = new Process();
startInfo.RedirectStandardInput = true;
startInfo.UseShellExecute = false;
startInfo.RedirectStandardOutput = true;
startInfo.RedirectStandardError = true;
startInfo.CreateNoWindow = true;
p = Process.Start(startInfo);
string xxx = p.StandardOutput.ReadToEnd();

获得标准输出的正确结果,需要增加以下代码

startInfo.StandardOutputEncoding = Encoding.GetEncoding(CultureInfo.CurrentCulture.TextInfo.OEMCodePage)

在苹果OSX系统下,使用jenkins shell时判断Unity是否在运行的方法

打包时,如果打包机(苹果OSX系统)的Unity正在运行,则会打包失败。为了尽早捕获这种异常,需要判定Unity是否在运行。 经过一番搜索,还是使用了最原始的判断进程关键字的方法。Unity在mac上运行时,ps 查看进程通常有/xx/xx/Unity -projectPath xxx特征,提取最精简部分,统计进程数量(wc -l输出行数),即可。使用如下方式进行判定,目前准确率还行,用一段时间试试看。

#!/bin/bash
if [ $(ps -ef | grep "Unity -projectPath" | wc -l) = "2" ]; then
    echo "The Unity instance is running, exit now!"
    exit 1
fi

关于bash:在sed命令中转义正斜杠

  1. 如果replace内容不包含/这种写法没问题sed"s/regex/replace/" file
  2. 如果replace内容包含/,则改变分割符号为|,完整写法为 sed"s|regex|replace|" file ,这样就不用为\写转义了

常用模拟器adb连接端口

::夜神安卓模拟器 62001
::逍遥安卓模拟器  21503
::蓝叠安卓模拟器  5555
::雷电安卓模拟器 5555
::天天安卓模拟器  5037
::网易MuMu模拟器  7555
::安卓模拟器大师  54001
::腾讯手游助手   5555

adb connect 127.0.0.1:62001
adb logcat -s Unity

koolshare最新软件中心1.5.8敏感词

如果提示检测到离线安装包名有非法关键词,开启路由器的SSH功能,登录并输入以下命令后,再进行离线安装。

sed -i 's/\tdetect_package/\t# detect_package/g' /koolshare/scripts/ks_tar_install.sh