You are not logged in.

#1 2016-06-19 08:47:11

whiskeytango3000
Member
Registered: 2016-06-19
Posts: 5

[SOLVED] bash for loop, iterating an array

New to scripting and this function has been an issue for me. I need to monitor feeds from different servers inside a VPN.
This function achieves that goal by creating a small window for each video feed.
And I can go back to the script's main menu or close the terminal without closing the vlc processes.

playallstreams() {
nohup cvlc --zoom 0.50 http://server1.com:9000/file1.flv &
nohup cvlc --zoom 0.50 http://server2.com:9000/file2.flv &
. . . more streams . . .
}

I tried the following loop. It either opens the first file and hangs
or, after adding feeds to the list for a total of 5, this code just opens server1's file1.flv 5 times. smile

streamlist=("http://server1.com:9000/file1.flv" "http://server2.com:9000/file2.flv" "...")
playallstreams() {
for i in "${streamlist[@]}"
  do
    nohup cvlc --options "${streamlist[@]}" &
  done
}

EDIT: Solved, ShellCheck said i was undefined. Changing i to streamlist worked.

Last edited by whiskeytango3000 (2016-06-19 09:46:13)

Offline

#2 2016-06-19 09:27:18

Saint0fCloud
Member
Registered: 2009-03-31
Posts: 137

Re: [SOLVED] bash for loop, iterating an array

nohup cvlc --options $i &

smile

Offline

#3 2016-06-19 09:31:18

whiskeytango3000
Member
Registered: 2016-06-19
Posts: 5

Re: [SOLVED] bash for loop, iterating an array

thank you

Offline

#4 2016-06-19 09:35:21

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,424
Website

Re: [SOLVED] bash for loop, iterating an array

Please remember to mark your thread as [Solved] by editing your first post and prepending it to the title.


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

Board footer

Powered by FluxBB