3
我想在Tcl/Tk中創建一個簡單的控制檯如何用TCL中的exec在兩個參數中分割一個變量?
我有兩個問題。首先用[glob *]更改每個*,但是當我的條目包含「ls -a」時,它不理解ls是命令並且第一個arg是-a
。
我該如何設法做到這一點?
感謝
proc execute {} {
# ajoute le contenu de .add_frame.add_entry
set value [.add_frame.add_entry get]
if {[string compare "$value" ""] == 1} {
.text insert end "\n\n% $value\n"
.text insert end [exec $value]
.add_frame.add_entry delete 0 end
}
}
frame .add_frame
label .add_frame.add_label -text "Nouvel élément : "
entry .add_frame.add_entry
button .add_frame.add_button -text "Executer" -command execute
button .add_frame.exit_button -text "Quitter" -command exit
bind .add_frame.add_entry <Return> execute
bind .add_frame.add_entry <KP_Enter> execute
bind . <Escape> exit
bind . <Control-q> exit
pack .add_frame.add_label -side left
pack .add_frame.exit_button -side right
pack .add_frame.add_button -side right
pack .add_frame.add_entry -fill x -expand true
pack .add_frame -side top -fill x
text .text
.text insert end "% Tcl/Tk Console"
pack .text -side bottom -fill both -expand true
+1的建議「SH -C $值」 - 你可能不希望建立在Tcl的一個shell解釋。 – 2010-09-14 15:09:59
但是,如果你真的想在Tcl中模擬shell語法,你可能想看看我的代碼http://wiki.tcl.tk/gush,特別是tokeinise和shellrun過程。 – 2010-09-15 18:58:28