1. 引入library
import subprocess
2. 定義函數
def get_cmd_line_results(input_string):
os.chdir(INET_DIR)
proc = subprocess.Popen(input_string, stdout=subprocess.PIPE, shell=True)
#"git symbolic-ref HEAD"
(out, err) = proc.communicate()
os.chdir(CUR_DIR)
return out[:-1]
3. 在主程式內容呼叫
inet_branch = get_cmd_line_results("git symbolic-ref HEAD")
這是我的工作酸甜苦辣,與大家分享,希望彼此都有收穫:) This is my working experience in my life. It is good to share with you :)
Friday, September 8, 2017
Tuesday, August 29, 2017
crontab usage rule in Linux
1. create new crontab task:
crontab -e
https://code.kpman.cc/2015/02/11/%E5%88%A9%E7%94%A8-crontab-%E4%BE%86%E5%81%9A-Linux-%E5%9B%BA%E5%AE%9A%E6%8E%92%E7%A8%8B/
2. delete crontab task text in "crontab -e":
crontab -r
3. lookup current crontab task in "crontab -e":
crontab -l
4. delete on-going crontab task:
For example:
(4-1) find the task executed by cron:
88588 88588 /usr/sbin/crond -n
160149 88588 \_ /usr/sbin/crond -n
134979 88588 \_ /usr/sbin/CROND -n
134982 134982 \_ /bin/sh -c python /dataVol/homes/yarco.yang/omnetpp/inet_11ax/examples/wireless/ieee80211ax/feature_test_script/auto_peak_txop_ps_per0.py 1 > ~/run_11ax_txop.log
134984 134982 | \_ python /dataVol/homes/yarco.yang/omnetpp/inet_11ax/examples/wireless/ieee80211ax/feature_test_script/auto_peak_txop_ps_per0.py 1
170760 134982 | \_ sh utility_script/vector_filter_fast.sh results/dntp-4STAs-11ax-AMSDU-UDP-AlgoA-4A0B-TXOP-4NSS-4.vec resul ...
(4-2) crontab start executing a python script, you can kill this python script task by
kill -9 134984
ref: https://superuser.com/questions/232144/how-to-stop-a-currently-running-cron-job/834110
crontab -e
https://code.kpman.cc/2015/02/11/%E5%88%A9%E7%94%A8-crontab-%E4%BE%86%E5%81%9A-Linux-%E5%9B%BA%E5%AE%9A%E6%8E%92%E7%A8%8B/
2. delete crontab task text in "crontab -e":
crontab -r
3. lookup current crontab task in "crontab -e":
crontab -l
4. delete on-going crontab task:
ps -o pid,sess,cmd afx
(4-1) find the task executed by cron:
88588 88588 /usr/sbin/crond -n
160149 88588 \_ /usr/sbin/crond -n
134979 88588 \_ /usr/sbin/CROND -n
134982 134982 \_ /bin/sh -c python /dataVol/homes/yarco.yang/omnetpp/inet_11ax/examples/wireless/ieee80211ax/feature_test_script/auto_peak_txop_ps_per0.py 1 > ~/run_11ax_txop.log
134984 134982 | \_ python /dataVol/homes/yarco.yang/omnetpp/inet_11ax/examples/wireless/ieee80211ax/feature_test_script/auto_peak_txop_ps_per0.py 1
170760 134982 | \_ sh utility_script/vector_filter_fast.sh results/dntp-4STAs-11ax-AMSDU-UDP-AlgoA-4A0B-TXOP-4NSS-4.vec resul ...
(4-2) crontab start executing a python script, you can kill this python script task by
kill -9 134984
ref: https://superuser.com/questions/232144/how-to-stop-a-currently-running-cron-job/834110
Tuesday, March 14, 2017
Thursday, October 27, 2016
Monday, June 27, 2016
strcat() like in AWK language
str_var = "abc"
str_var = str_var "your new string"
Please refer to
http://www.unix.com/unix-for-dummies-questions-and-answers/12459-awk-question.html
str_var = str_var "your new string"
Please refer to
http://www.unix.com/unix-for-dummies-questions-and-answers/12459-awk-question.html
Sunday, June 26, 2016
Friday, April 1, 2016
OMNeT++/OMNEST priority schedule for the event at the same time
In OMNeT++/OMNEST, sometimes two events may arrive at the same time. However, the OMNeT++/OMNEST can only handle both events in sequence based on the arrival time of each event. If we hope to always handle a event before the other event, we can use the following function to handle this problem.
where p is the priority, the smaller number of p has higher priority.
refer to.
https://omnetpp.org/doc/omnetpp/api/classcMessage.html#a205278b4eaf8a54a901537f6e6cfae59
Examples:
cMessage *timer1 = new cMessage("tiemr1");
cMessage *timer2 = new cMessage("tiemr2");
timer1->setSchedulingPriority(1); // lower priority
timer1->setSchedulingPriority(-1); // high priority
send(timer1, Gate);
send(timer2, Gate);
setSchedulingPriority(short p)
where p is the priority, the smaller number of p has higher priority.
refer to.
https://omnetpp.org/doc/omnetpp/api/classcMessage.html#a205278b4eaf8a54a901537f6e6cfae59
Examples:
cMessage *timer1 = new cMessage("tiemr1");
cMessage *timer2 = new cMessage("tiemr2");
timer1->setSchedulingPriority(1); // lower priority
timer1->setSchedulingPriority(-1); // high priority
send(timer1, Gate);
send(timer2, Gate);
Subscribe to:
Posts (Atom)