How to search a digit i.e process id in tcl and kill the process id

前端 未结 4 819
隐瞒了意图╮
隐瞒了意图╮ 2021-01-27 09:48

I have tried to search process id i-e 6762 stored in a variable say buffer

nohup tcpdump -ni  eth0 -s0  2>&1          


        
4条回答
  •  抹茶落季
    2021-01-27 10:32

    Some of the problems with the code snippet above:

    • missing line continuation characters
    • missing closing quotes
    • info exists should be on pid and not $pid

    Try the snippet below and see if it helps:

    foreach line [split $buffer "\n"] \
    {
        if {[regexp {\[\d\]\s+(\d+)} $line junk pid]} \
        {
            break
        }
    }
    
    if {[info exists pid]} \
    {
        puts "PID of nohup is $pid"
    }
    

提交回复
热议问题