0

I want to launch multiple sites (selected by zenity checkmarks). I have been successful but a little trouble.

#!/bin/bash
browser=$(zenity --list  --text "Which browser?" --radiolist  --column "Pick" --column "Browser" TRUE firefox FALSE opera)
sites=$(zenity --height=280 --width=300 --list  --text "How linux.byexamples can be improved?" --checklist  --column "Pick" --column "Sites" TRUE http://cr4.globalspec.com/ TRUE http://www.cheresources.com/ TRUE http://www.eng-tips.com/ FALSE http://www.engineersedge.com/ FALSE http://hvac-talk.com/vbb/ FALSE http://www.refrigeration-engineer.com/ FALSE http://engineering.stackexchange.com/ FALSE http://chemistry.stackexchange.com/ --separator=" ")
$browser $sites

If my firefox is already running & I check more than one site to open in firefox, the checked websites will open in a new firefox window, instead of existing window & new tabs. This doesn't happen if I check single site. The problem can be circumvented if I use something like

$browser site1
$browser site2 ...

So how can I slice the output (collection of websites separated by space character) produced by zenity & then chain through each of them as indicated?

4

1 回答 1

1

您可以通过这种方式迭代(并因此一一打开)$sites

#!/bin/bash

browser=$(zenity --list  --text "Which browser?" --radiolist  --column "Pick" --column "Browser" TRUE firefox FALSE opera)

sites=$(zenity --height=280 --width=300 --list  --text "How linux.byexamples can be improved?" --checklist  --column "Pick" --column "Sites" TRUE http://cr4.globalspec.com/ TRUE http://www.cheresources.com/ TRUE http://www.eng-tips.com/ FALSE http://www.engineersedge.com/ FALSE http://hvac-talk.com/vbb/ FALSE http://www.refrigeration-engineer.com/ FALSE http://engineering.stackexchange.com/ FALSE http://chemistry.stackexchange.com/ --separator=" ")

for site in $sites; do
  $browser $site
done
于 2016-05-18T12:43:53.753 回答