Results 1 to 3 of 3

Thread: Bash script help

  1. #1
    Join Date
    Jun 2008
    Location
    Switzerland
    Beans
    51
    Distro
    Ubuntu 12.04 Precise Pangolin

    Bash script help

    PHP Code:
    for i in 11 71 16 17 21 26 28 42 43 26 19 2 22 3 25 64 69 58
    do
    URL="http://127.0.0.1:8000/live/admin/12drf2vjVOm/$i.ts"

    HAS_AAC_OUT=$(ffmpeg -i $URL 2>&grep 48000)
    if [ -
    "$HAS_AAC_OUT];then
      FILE
    =${URL##*/}
    if
      echo 
    "ERRORTS=${FILE%.*}"

    exit 1
    else
    echo 
    "$i"

    fi
    done
    exit 
    I would like to see the assigned variable instead of i value. For example 11=ATA 17=CCC etc

    How can use if like this:

    if i=11 then
    echo "ERRORTS=ATA"

    if i=17 then
    echo "ERRORTS=CCC"

    the current script gives me the i value if the stream has no parameter as AAC

    ERRORTS=11

    I have to check 11 every time for real value. If I owuld do that I won't have to check.

    many thanks in advance
    Last edited by YaPaY; June 19th, 2017 at 01:39 PM.

  2. #2
    Join Date
    Nov 2008
    Location
    Metro Boston
    Beans
    13,304
    Distro
    Kubuntu 18.04 Bionic Beaver

    Re: Bash script help

    You could try using the "case" construct in bash:
    Code:
    case "$i" in
       ATA)
       do stuff
       ;;
    
       CCC)
       do other stuff
       ;;
    
       *)
       throw error?
       ;;
    esac
    If you ask for help, do not abandon your request. Please have the courtesy to check for responses and thank the people who helped you.

    Blog · Linode System Administration Guides · Android Apps for Ubuntu Users

  3. #3
    Join Date
    Jun 2008
    Location
    Switzerland
    Beans
    51
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: Bash script help

    thanks but I am not a programmer

Bookmarks

Posting Permissions

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