When Tcl/expect uses Exec to invoke a slightly more complex shell command, it often encounters minor problems, usually pipeline (|) and awk.
When Tcl/expect calls multiple shell commands and uses | To string them together, it is important to note that the "|" Before and after the sky "", otherwise tcl/expect will report strange mistakes.
When Tcl/expect invokes the awk command, you need to change the command in awk to "", and change the $ and $ variable to/$1,/$2.
The following Ksh command determines whether the test_process is running:
Ps-fu bonny|grep-v ps|grep mmcap|grep-v Grep|awk ' {print $} '
After changing to Tcl/expect, it is:
EXEC Ps-fu $myname | Grep-v PS | grep Coolrunmmcap | Grep-v grep | awk "{Print/$2}"
In addition, http://www.linuxquestions.org/questions/linux-software-2/ksh-tcl-173092/lists some of the problems that are frequently encountered when converting KSH commands into TCL statements (which I have never verified, Please use it carefully).
Here's some conversion rules that I have proven, if anyone has any more info (in any fashion), please advise.
-----------------------------------------------------------------
Rule:remove "
-----------------------------------------------------------------
Ksh:cat *.passwd 2>/dev/null | Cut-d ":"-F1 | Sort | Uniq
Tcl:exec Cat *.passwd 2>/dev/null | Cut-d:-f1 | Sort | Uniq
-----------------------------------------------------------------
-----------------------------------------------------------------
Rule:replace ' (.. $.) ' With "{.. /$1..} "
-----------------------------------------------------------------
Ksh:ps-eaf | awk ' (Print} ' | grep $2>&1
Tcl:exec Ps-eaf | awk "{print/$1}" | grep $user _login_to_test
-----------------------------------------------------------------
-----------------------------------------------------------------
Rule:replace "..." with {...}
-----------------------------------------------------------------
Ksh:grep "^$ (user_login:"/etc/passwd/etc/shadow 2>&1
tcl:exec grep {^ $user _login:}/etc/passwd/etc/shadow
-----------------------------------------------------------------
-----------------------------------------------------------------
Rule:replace ' ... ' with ' ... ' or {...}
-----------------------------------------------------------------
Ksh:grep ' Version ' USER.TCL
tcl:exec grep {Version} USER.TCL
tcl:exec grep "Version" USER.TCL
-----------------------------------------------------------------
And there's the http://wiki.tcl.tk/1039. Lists some common problems with exec.