Find the answer to your Linux question:
Results 1 to 2 of 2
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    shell script execution sequence

    I'm debugging a shell script so I add set -x at the beginning a code snippet are as below
    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
    ++ sleep 5
    ++ sudo -u esolve firefox /tor_capture/flash.html
    ++ tcpdump -i eth0 host 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

    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
    $ echo "bla bla bla bla bla" & echo "bla" &
    bla bla bla bla bla
    $ { echo "bla bla bla bla bla"; echo "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