java呼叫shell,sed命令的問題

2021-08-29 13:01:14 字數 447 閱讀 5899

採用process process = runtime.getruntime().exec(); 呼叫ping,ls,ps命令都能得到結果!!

但為什麼直接呼叫sed命令對檔案操作就不行了,把sed命令寫到shell指令碼,調這個指令碼就行呢??

**清單

string str="sed -i 's/10.2.0.221/10.2.0.233/g' /etc/rc.local";

runtime rt=runtime.getruntime().exec(str);

bufferedreader br = new bufferedreader(new inputstreamreader(rt.getinputstream()));

string line=null;

while((line = br.readline()) != null)

br.closs();

Python基礎 呼叫shell和cmd命令

啟動 catcmd adb s tvip 5555 logcat v time logpath printcatcmd self lcprocess subprocess.popen catcmd stdout subprocess.pipe stderr subprocess.pipe shell...

java 遞迴呼叫

遞迴呼叫是呼叫自身的函式,並傳給自身的相應的引數,這一運算過程是一層層的進行的,直到滿足一定條件時,才停止呼叫。遞迴函式的特點 1.函式要直接或間接呼叫自身。2.要有遞迴終止條件檢查,即遞迴終止的條件被滿足後,則不再呼叫自身函式。3.如果不滿足遞迴終止的條件,則呼叫涉及遞迴呼叫的表示式 在呼叫函式自...

linux C程式中呼叫shell終端的命令

使用popen 在學習unix程式設計的過程中,發現系統還提供了乙個popen函式,可以非常簡單的處理呼叫shell,其函式原型如下 file popen const char command,const char type 該函式的作用是建立乙個管道,fork乙個程序,然後執行shell,而she...