当我运行命令
时 awk '/^proc/ {print $2}' <file_name>
Tcl
脚本中使用exec
函数作为时使用它
exec awk "/^proc/ {print $2}" win_test.tcl
,
我接受error can't read "2": no such variable
答案 0 :(得分:3)
使用单引号括起exec
命令,然后使用set awkCmd {/^proc/ {print $2}}
exec awk $awkCmd <file-name>
。
[dinesh@mypc mypgms]$ cat sample.tcl
proc Hello {} {
}
proc World {} {
}
[dinesh@mypc mypgms]$ tclsh
% set awkCmd {/^proc/ {print $2}}
/^proc/ {print $2}
% exec awk $awkCmd sample.tcl
Hello
World
%
示例强>
var Progressajax2 = false;
$(document).ready(function() {
$(".closeclass").on('click',function() {
if(Progressajax2)
return;
Progressajax2 = true;
var element = $(this);
var I = element.attr("id");
var value = element.attr("value");
var pagecont = $('.pagecont'+value).val();
var contcomments = $('.contcomments'+value).text();
if(confirm('Are you sure?')) {
$.ajax({
type: "POST",
url: "/delete.php",
data: "id="+I,
success: function() {
Progressajax2 = false;
pagecont = parseInt(pagecont)-parseInt(1);
contcomments = parseInt(contcomments)-parseInt(1);
$('.pagecont'+value).val(pagecont);
}
});
}
});
});