Decode a hex string by using look up table
char m_table['f' + 1]['f' + 1] = {0}; void initDecodeTable() { const char * hexValue = "0123456789abcdefABCDEF"; int len = strlen(hexValue); for(int i=0;i < len;i++) { for(int j=0;j int v; char tmp[2] = { tolower(hexValue[i]), tolower(hexValue[j]) }; sscanf(tmp, "%x", &v); m_table[hexValue[i]][hexValue[j]] = (v & 0xFF); } } } void decodeHex(const char * pIn, int inLen, char * pOut, int & outLen) { outLen = inLen / 2; for(int i=0; i < outLen;i++) { pOut[i] = m_table[pIn[i * 2]][pIn[i * 2 + 1]]; } if (inLen % 2 !
通过一些ssh的客户端,可以很方便的做ssh forward,也就是通过一台主机上ssh连接到另一台主机,那么命令行可不可以呢?
只要在~/.ssh/config中加入如下指令即可
host serverB.example.com serverB ProxyCommand ssh -W %h:%p gateway serverB是最终的目的主机,gateway是中间转发的主机,gateway上需要配置无密码登录。
或者暴力一点
ssh -t usergateway@gateway ssh user1@serverb
在unix,maxosx或者linux下工作的时候,经常需要长时间运行一个程序,通常会把程序放到后台,然后通过日志来监控。
如果使用screen的话,可以让程序保持前台运行,又能通过detach放到后台。
如果在公司机器上用screen运行一个程序,然后detach,回家后通过ssh连接公司机器,用screen restore就可以继续观察程序运行了。
可是如果一开始没有用screen运行,直接放置到后台怎么办呢。reptyr就派上用场了,以下是reptyr的说明
reparent a orphan background process, means background a process in a terminal and bring it back to foreground to another terminal reptyr - A tool for "re-ptying" programs. ----------------------------------------- reptyr is a utility for taking an existing running program and attaching it to a new terminal. Started a long-running process over ssh, but have to leave and don't want to interrupt it? Just start a screen, use reptyr to grab it, and then kill the ssh session and head on home.