Find the answer to your Linux question:
Results 1 to 2 of 2
I'm debugging a shell script so I add set -x at the beginning a code snippet are as below Code: tcpdump -i $interface host $ip_addr and 'port 80' -w flash/flash.pcap ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    May 2012
    Posts
    87

    shell script execution sequence


    I'm debugging a shell script so I add set -x at the beginning a code snippet are as below
    Code:
    tcpdump -i $interface host $ip_addr and 'port 80' -w flash/flash.pcap &
    sudo -u esolve firefox /tor_capture/flash.html &
    sleep $capture_time
    but I noticed that the execution sequence is as below
    Code:
    ++ sleep 5
    ++ sudo -u esolve firefox /tor_capture/flash.html
    ++ tcpdump -i eth0 host 138.96.192.56 and 'port 80' -w flash/flash.pcap
    tcpdump: listening on eth0, link-type EN10MB (Ethernet), capture size 65535 bytes
    so the execution sequence is reversed compared to the command sequence in the script what is wrong with this and how to deal with it? thanks!

  2. #2
    Linux Newbie
    Join Date
    Nov 2012
    Posts
    226
    hi,

    when in background commands do not wait for the previous to be finished to start and end, so it might end before.

    group commands between curly braces
    Code:
    $ echo "bla bla bla bla bla" & echo "bla" &
    bla
    bla bla bla bla bla
    $ { echo "bla bla bla bla bla"; echo "bla";} &
    bla bla bla bla bla
    bla

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •