Bash script to display a series of graphs on different tabs
-
- Lemon Pip
- Posts: 71
- Joined: November 30th, 2017, 11:14 am
Bash script to display a series of graphs on different tabs
I have written a bash script which works on linux boxes. (tested on ububtu 8 & puppy wary 5.3)
It downloads just the charts from stockcharts
I used a box with a P4 cpu and 256mb ram - the script has very low hardware demands - no java!!!!! and page loads are very fast (even with puppy using up some of that ram)
For other versions of linux you may need to change the last lines depending on how your console calls your default browser this may need some googling or asking qus on user forums
Only got a windows box?
Then use puppy - it runs as a live cd
Any interest?
It downloads just the charts from stockcharts
I used a box with a P4 cpu and 256mb ram - the script has very low hardware demands - no java!!!!! and page loads are very fast (even with puppy using up some of that ram)
For other versions of linux you may need to change the last lines depending on how your console calls your default browser this may need some googling or asking qus on user forums
Only got a windows box?
Then use puppy - it runs as a live cd
Any interest?
-
- Lemon Half
- Posts: 8675
- Joined: November 4th, 2016, 1:16 pm
Re: Bash script to display a series of graphs on different tabs
We've got something similar that works on HTML and hence cross-platform, and just loads into whatever browser you want to use.schober wrote:
Only got a windows box?
Some details here, and also a link to the example HTML file, which can be edited in a simple text editor to suit the appropriate EPIC list that anyone wants to use -
http://lemonfoolfinancialsoftware.weebl ... harts.html
http://lemonfoolfinancialsoftware.weebl ... _v2_0.html
Cheers,
Itsallaguess
-
- Lemon Quarter
- Posts: 3865
- Joined: November 4th, 2016, 9:24 am
Re: Bash script to display a series of graphs on different tabs
There's many ways to skin a cat (and I like skinning cats
)
Can you publish your Bash script, I'm sure we (or, at least I) could learn something from it.
--kiloran
![Very Happy :D](./images/smilies/icon_e_biggrin.gif)
Can you publish your Bash script, I'm sure we (or, at least I) could learn something from it.
--kiloran
-
- Lemon Quarter
- Posts: 4108
- Joined: November 4th, 2016, 9:42 pm
Re: Bash script to display a series of graphs on different tabs
You do know that Windows 10 has been able to run native Linux apps/commands for over a year now?schober wrote:Only got a windows box?
Then use puppy - it runs as a live cd
https://www.howtogeek.com/249966/how-to ... indows-10/How-To Geek wrote:Windows 10’s Anniversary Update offers a big new feature for developers: A full, Ubuntu-based Bash shell that can run Linux software directly on Windows.
-
- Lemon Pip
- Posts: 71
- Joined: November 30th, 2017, 11:14 am
Re: Bash script to display a series of graphs on different tabs
Hi all
1) yes, i'm aware of the LC html script
2) My script works very well if you have tab wheel scrolling (sea monkey & chrome do, palemoon doesnt)
3) You get a series of tabs like this - couldnt post url!
4) This is it
Save it as stckchrts & make it executable
Open up a terminal window
Type the command stckchrts and follow the instructions; use newline for each entry
Lines 42/43 may need attention depending on your OS
1) yes, i'm aware of the LC html script
2) My script works very well if you have tab wheel scrolling (sea monkey & chrome do, palemoon doesnt)
3) You get a series of tabs like this - couldnt post url!
4) This is it
Save it as stckchrts & make it executable
Open up a terminal window
Type the command stckchrts and follow the instructions; use newline for each entry
Lines 42/43 may need attention depending on your OS
Code: Select all
#!/bin/bash
i=0
f_ar=()
req=()
echo "Enter Mkt then Stocks & end with xx"
echo "US = us; UK = uk; Canada = ca; Venture exchge = v"
while read line; do
req[$i]="$line"
if [[ $line = "xx" ]]; then break; fi
let i=i+1 #$(($i+1))
done #< "$file" #/home/mike/Documents/Signet/b_charts
echo "req ${req[@]}"
echo "req0 ${req[0]}"
mk="${req[0]}"
mkt=$(echo "$mk" | tr '[:upper:]' '[:lower:]') # convert to lower case
echo "Mkt $mkt"
arr=()
a1=()
a1=$(echo ${req[@]} | rev | cut -d" " --complement -f1 | rev) # remove last item (xx)
a2=$(echo ${a1[@]} | cut -d" " --complement -f1) # remove first item (uk, us, ca)
a3=$(echo "$a2" | tr '[:lower:]' '[:upper:]') # convert to upper case
arr=(${a3}) # convert string to array
echo "Stock list is ${arr[@]}"
for t in "${arr[@]}"
do
start="http://www.stockcharts.com/c-sc/sc?s="
if [ "$mkt" == "us" ]
then end="&p=D&yr=1&mn=0&dy=0&i=t18680472715&r=1503841764277"
elif [ "$mkt" == "uk" ]
then end=".L&p=D&yr=5&mn=0&dy=0&i=t40345613568&r=1503767028109"
elif [ "$mkt" == "ca" ]
then end=".TO&p=D&yr=5&mn=0&dy=0&i=t77110325637&r=1503766992765"
elif [ "$mkt" == "v" ]
then end=".V&p=D&yr=5&mn=0&dy=0&i=t88088727052&r=1503768309990"
fi
epic="$t"
# http://stockcharts.com/c-sc/sc?s=URI&p=D&b=5&g=0&i=0&r=1512824351853
url=$start$epic$end
echo " url is $url"
#x-www-browser $url # use in ubuntu
defaultbrowser $url # use in puppy - default stored in file /usr/local/bin/defaultbrowser
done
-
- Posts: 28
- Joined: November 10th, 2016, 12:49 am
Re: Bash script to display a series of graphs on different tabs
Hi schober
Thanks for putting up your script to access stockcharts.com. Nice idea. I was intrigued by bash arrays and, it being a boring Saturday night, had a poke around. Um, it sort of, er, evolved... no new functionality unfortunately (I wanted to add DAX tickers, but no dice), however people might find it interesting and perhaps easier to modify. Anyway, it turns out that bash arrays aren't really needed (bash can loop happily over space separated strings), also I've broken things out into a lot of small functions and put in some error messages. I've tried it with firefox and chrome and it seems ok, firing off multiple tabs just fine.
As with your original 'stckchrts' script, the thing can be driven from the command line interactively:
or by supplying a pre-prepared file with the market code name (us, uk, ca, v) on the first line, followed by one or more tickers on subsequent lines:
Save the following as 'stckchrts2':
Thanks for putting up your script to access stockcharts.com. Nice idea. I was intrigued by bash arrays and, it being a boring Saturday night, had a poke around. Um, it sort of, er, evolved... no new functionality unfortunately (I wanted to add DAX tickers, but no dice), however people might find it interesting and perhaps easier to modify. Anyway, it turns out that bash arrays aren't really needed (bash can loop happily over space separated strings), also I've broken things out into a lot of small functions and put in some error messages. I've tried it with firefox and chrome and it seems ok, firing off multiple tabs just fine.
As with your original 'stckchrts' script, the thing can be driven from the command line interactively:
Code: Select all
bash stckchrts2
Code: Select all
bash stckchrts2 < data_file
Code: Select all
#!/bin/bash
###########################################################################
#URL bases
STOCKCHARTS_URL_BASE='http://www.stockcharts.com/c-sc/sc?'
#Which browser? choose from: { firefox, chrome, system, none }
#BROWSER=none
BROWSER=firefox
#If you want to use a particular firefox profile, set it here
#FIREFOX_PROFILE='-P finance'
FIREFOX_PROFILE=
#Seconds to delay between browser calls
BROWSER_DELAY=4
###########################################################################
#reads until non-empty string or xx or EOF (^D)
#returns value read in variable named in $1
read_until () {
var=$1
local line
while read line; do
[[ "$line" = "xx" ]] && return #finished
[[ -z "$line" ]] && continue #skip blank
eval "$var=$line"
break
done
}
#reads all non-blank strings until xx or EOF (^D)
#returns concatenated strings in variable named in $1
read_while () {
var=$1
local line
while read line; do
[[ "$line" = "xx" ]] && return #finished
[[ -z "$line" ]] && continue #skip blank
eval "$var+=' $line'" #append with leading blank
done
}
#Sets globals:
# 'market' as lowercase string
# 'epics' as string of space-separated uppercase epics
read_data () {
echo "Enter Mkt then Stocks & end with xx or hit ^D (or ^C to abort)"
echo "US = us; UK = uk; Canada = ca; Venture exchge = v"
read_until market
[[ -z "$market" ]] && echo "no market supplied" 1>&2 && exit 1
read_while epics
[[ -z "$epics" ]] && echo "no epics supplied" 1>&2 && exit 1
market=$(echo $market | tr 'A-Z' 'a-z') #to lower
epics=$(echo $epics | tr 'a-z' 'A-Z') #to upper
}
#Builds a URL from components; sets global 'url'
assemble_url () {
url=$1$2
shift; shift
for i in $*; do
url+="&$i"
done
}
#Builds a URL for stockcharts
stockcharts_url () {
case $1 in
us)
assemble_url $STOCKCHARTS_URL_BASE s=$2 \
p=D yr=5 mn=0 dy=0 i=t18680472715 r=1503841764277
;;
uk)
assemble_url $STOCKCHARTS_URL_BASE s=$2.L \
p=D yr=5 mn=0 dy=0 i=t40345613568 r=1503767028109
;;
ca)
assemble_url $STOCKCHARTS_URL_BASE s=$2.TO \
p=D yr=5 mn=0 dy=0 i=t77110325637 r=1503766992765
;;
v)
assemble_url $STOCKCHARTS_URL_BASE s=$2.V \
p=D yr=5 mn=0 dy=0 i=t88088727052 r=1503768309990
;;
*)
echo "unknown market '$1'" 1>&2
exit 1
esac
}
#Start or connect to a running web browser and open a URL in a new tab
#Discard annoying shell error messages from firefox
browse () {
case $BROWSER in
firefox)
browse_firefox --new-tab "$@"
;;
chrome)
browse_chrome --new-tab "$@"
;;
system)
browse_system --new-tab "$@"
;;
none)
#echo browse: none "$@"
;;
*)
browse_system --new-tab "$@"
;;
esac |& grep -v GLib-GObject-CRITICAL | grep -v '^ *$'
}
browse_firefox () {
#echo browse: firefox $@ && return
if [[ -x /usr/bin/firefox ]]; then
/usr/bin/firefox $FIREFOX_PROFILE "$@"
return
fi
firefox $FIREFOX_PROFILE "$@"
}
browse_chrome () {
#echo browse: chrome $@ && return
if [[ -x /usr/bin/google-chrome ]]; then
/usr/bin/google-chrome "$@"
return
fi
google-chrome "$@"
}
browse_system () {
#echo browse: system $@ && return
if [[ -x /usr/local/bin/defaultbrowser ]]; then
/usr/local/bin/defaultbrowser "$@" #puppy linux
return
fi
if [[ -x /usr/bin/x-www-browser ]]; then
/usr/bin/x-www-browser "$@" #ubuntu
return
fi
}
###########################################################################
# main
###########################################################################
read_data
[[ -z "$market" ]] && echo "no market supplied" 1>&2 && exit 1
[[ -z "$epics" ]] && echo "no epics supplied" 1>&2 && exit 1
echo "market: $market"
echo "epics: $epics"
#iterate over the epics, build a URL, and invoke a browser in the background
for epic in $epics; do
stockcharts_url $market $epic
echo "url: $url"
browse $url &
sleep $BROWSER_DELAY
done
exit 0
###########################################################################
-
- Lemon Pip
- Posts: 71
- Joined: November 30th, 2017, 11:14 am
Re: Bash script to display a series of graphs on different tabs
Thanks for the input desmid. You look to be on a higher paygrade than me!
I tried your version and got this error
/root/my-applications/bin/stckchrtslem: line 115: syntax error near unexpected token `&'
/root/my-applications/bin/stckchrtslem: line 115: ` esac | & grep -v GLib-GObject-CRITICAL | grep -v '^ *$''
Im using GNU bash, version 3.00.16(1)-release (i486-t2-linux-gnu)
The browser call at lines 42/43 can simply done with
mozilla $url
and this calls Sea Monkey
I tried your version and got this error
/root/my-applications/bin/stckchrtslem: line 115: syntax error near unexpected token `&'
/root/my-applications/bin/stckchrtslem: line 115: ` esac | & grep -v GLib-GObject-CRITICAL | grep -v '^ *$''
Im using GNU bash, version 3.00.16(1)-release (i486-t2-linux-gnu)
The browser call at lines 42/43 can simply done with
mozilla $url
and this calls Sea Monkey
-
- Posts: 28
- Joined: November 10th, 2016, 12:49 am
Re: Bash script to display a series of graphs on different tabs
Heh! I wish - I'd like to be on any paygrade right now...schober wrote:Thanks for the input desmid. You look to be on a higher paygrade than me!
I tried your version and got this error
/root/my-applications/bin/stckchrtslem: line 115: syntax error near unexpected token `&'
/root/my-applications/bin/stckchrtslem: line 115: ` esac | & grep -v GLib-GObject-CRITICAL | grep -v '^ *$''
Im using GNU bash, version 3.00.16(1)-release (i486-t2-linux-gnu)
The browser call at lines 42/43 can simply done with
mozilla $url
and this calls Sea Monkey
![Smile :)](./images/smilies/icon_e_smile.gif)
The bug at line 115 must be a bash version thing - since mine is GNU bash 4.3.11(1), I suppose the "|&" construct (that I use in zsh) might be newer. Attached is another version with that hopefully fixed in the older redirection syntax.
I just installed SeaMonkey to try out - looks useful, especially with the dire things Mozilla are doing to firefox vis-à-vis add-ons, so I might switch - thanks for the pointer.
This version of the code purports to know about seamonkey aka mozilla as well, but you might have to adapt it (if interested, that is):
Code: Select all
#!/bin/bash
###########################################################################
#URL bases
STOCKCHARTS_URL_BASE='http://www.stockcharts.com/c-sc/sc?'
#Which browser? choose from: { firefox, seamonkey, chrome, system, none }
#BROWSER=none
BROWSER=seamonkey
#If you want to use a particular firefox/seamonkey profile, set it here
#FIREFOX_PROFILE='-P finance'
FIREFOX_PROFILE=
#Seconds to delay between browser calls
BROWSER_DELAY=4
###########################################################################
#reads until non-empty string or xx or EOF (^D)
#returns value read in variable named in $1
read_until () {
var=$1
local line
while read line; do
[[ "$line" = "xx" ]] && return #finished
[[ -z "$line" ]] && continue #skip blank
eval "$var=$line"
break
done
}
#reads all non-blank strings until xx or EOF (^D)
#returns concatenated strings in variable named in $1
read_while () {
var=$1
local line
while read line; do
[[ "$line" = "xx" ]] && return #finished
[[ -z "$line" ]] && continue #skip blank
eval "$var+=' $line'" #append with leading blank
done
}
#Sets globals:
# 'market' as lowercase string
# 'epics' as string of space-separated uppercase epics
read_data () {
echo "Enter Mkt then Stocks & end with xx or hit ^D (or ^C to abort)"
echo "US = us; UK = uk; Canada = ca; Venture exchge = v"
read_until market
[[ -z "$market" ]] && echo "no market supplied" 1>&2 && exit 1
read_while epics
[[ -z "$epics" ]] && echo "no epics supplied" 1>&2 && exit 1
market=$(echo $market | tr 'A-Z' 'a-z') #to lower
epics=$(echo $epics | tr 'a-z' 'A-Z') #to upper
}
#Builds a URL from components; sets global 'url'
assemble_url () {
url=$1$2
shift; shift
for i in $*; do
url+="&$i"
done
}
#Builds a URL for stockcharts
stockcharts_url () {
case $1 in
us)
assemble_url $STOCKCHARTS_URL_BASE s=$2 \
p=D yr=5 mn=0 dy=0 i=t18680472715 r=1503841764277
;;
uk)
assemble_url $STOCKCHARTS_URL_BASE s=$2.L \
p=D yr=5 mn=0 dy=0 i=t40345613568 r=1503767028109
;;
ca)
assemble_url $STOCKCHARTS_URL_BASE s=$2.TO \
p=D yr=5 mn=0 dy=0 i=t77110325637 r=1503766992765
;;
v)
assemble_url $STOCKCHARTS_URL_BASE s=$2.V \
p=D yr=5 mn=0 dy=0 i=t88088727052 r=1503768309990
;;
*)
echo "unknown market '$1'" 1>&2
exit 1
esac
}
#Start or connect to a running web browser and open a URL in a new tab
#Discard annoying shell error messages from firefox
browse () {
case $BROWSER in
firefox)
browse_firefox --new-tab "$@"
;;
seamonkey)
browse_seamonkey --new-tab "$@"
;;
chrome)
browse_chrome --new-tab "$@"
;;
system)
browse_system --new-tab "$@"
;;
none)
#echo browse: none "$@"
;;
*)
browse_system --new-tab "$@"
;;
esac 2>&1 | grep -v GLib-GObject-CRITICAL | grep -v '^ *$' 1>&2
}
browse_firefox () {
#echo browse: firefox $@ && return
if [[ -x /usr/bin/firefox ]]; then
/usr/bin/firefox $FIREFOX_PROFILE "$@"
return
fi
#try user's path
firefox $FIREFOX_PROFILE "$@"
}
browse_seamonkey () {
#echo browse: seamonkey $@ && return
#try to find seamonkey or mozilla in likely places
if [[ -x /usr/local/bin/mozilla ]]; then
/usr/local/bin/mozilla $FIREFOX_PROFILE "$@"
return
fi
if [[ -x /usr/local/bin/seamonkey ]]; then
/usr/local/bin/seamonkey $FIREFOX_PROFILE "$@"
return
fi
#try user's path
mozilla $FIREFOX_PROFILE "$@" > /dev/null 2>&1 || seamonkey $FIREFOX_PROFILE "$@"
}
browse_chrome () {
#echo browse: chrome $@ && return
if [[ -x /usr/bin/google-chrome ]]; then
/usr/bin/google-chrome "$@"
return
fi
#try user's path
google-chrome "$@"
}
browse_system () {
#echo browse: system $@ && return
if [[ -x /usr/local/bin/defaultbrowser ]]; then
/usr/local/bin/defaultbrowser "$@" #puppy linux
return
fi
if [[ -x /usr/bin/x-www-browser ]]; then
/usr/bin/x-www-browser "$@" #ubuntu
return
fi
}
###########################################################################
# main
###########################################################################
read_data
[[ -z "$market" ]] && echo "no market supplied" 1>&2 && exit 1
[[ -z "$epics" ]] && echo "no epics supplied" 1>&2 && exit 1
echo "market: $market"
echo "epics: $epics"
#iterate over the epics, build a URL, and invoke a browser in the background
for epic in $epics; do
stockcharts_url $market $epic
echo "url: $url"
browse $url &
sleep $BROWSER_DELAY
done
exit 0
###########################################################################
-
- Lemon Pip
- Posts: 71
- Joined: November 30th, 2017, 11:14 am
Re: Bash script to display a series of graphs on different tabs
Tried v2 but there seems to be an error early on; unfortunately my bash knowledge isn't up to finding the mistake. I got this
# stckchrtslem
Enter Mkt then Stocks & end with xx or hit ^D (or ^C to abort)
US = us; UK = uk; Canada = ca; Venture exchge = v
uk
pru
/root/my-applications/bin/stckchrtslem: line 41: epics+= pru: command not found
# stckchrtslem
Enter Mkt then Stocks & end with xx or hit ^D (or ^C to abort)
US = us; UK = uk; Canada = ca; Venture exchge = v
uk
pru
/root/my-applications/bin/stckchrtslem: line 41: epics+= pru: command not found
-
- Posts: 28
- Joined: November 10th, 2016, 12:49 am
Re: Bash script to display a series of graphs on different tabs
Interesting - this has the same bash version feel as the previous problem and I note that your test environments (ububtu 8 & puppy wary 5.3, from your original post) are about 8 and 6 years old, respectively. Fair enough, since Puppy is targeted at small/old hardware.schober wrote:Tried v2 but there seems to be an error early on; unfortunately my bash knowledge isn't up to finding the mistake. I got this
# stckchrtslem
Enter Mkt then Stocks & end with xx or hit ^D (or ^C to abort)
US = us; UK = uk; Canada = ca; Venture exchge = v
uk
pru
/root/my-applications/bin/stckchrtslem: line 41: epics+= pru: command not found
I've changed the script to use the lowest common denominator syntax: rather than 'bash', it's now just good old Bourne shell, 'sh', so that should work with any bash (Bourne Again SHell) as well as with other sh inplementations (dash, busybox). The other option is to upgrade your system!
Code: Select all
#!/bin/sh
###########################################################################
#URL bases
STOCKCHARTS_URL_BASE='http://www.stockcharts.com/c-sc/sc?'
#Which browser? choose from: { firefox, seamonkey, chrome, system, none }
#BROWSER=none
BROWSER=seamonkey
#If you want to use a particular firefox/seamonkey profile, set it here
#FIREFOX_PROFILE='-P finance'
FIREFOX_PROFILE=
#Seconds to delay between browser calls
BROWSER_DELAY=4
###########################################################################
#reads until non-empty string or xx or EOF (^D)
#returns value read in variable named in $1
read_until () {
var=$1
local line
while read line; do
[ "$line" = "xx" ] && return #finished
[ -z "$line" ] && continue #skip blank
eval "$var=$line"
break
done
}
#reads all non-blank strings until xx or EOF (^D)
#returns concatenated strings in variable named in $1
read_while () {
var=$1
local line
while read line; do
[ "$line" = "xx" ] && return #finished
[ -z "$line" ] && continue #skip blank
eval "$var=\"\$$var $line\"" #append with leading blank
done
}
#Sets globals:
# 'market' as lowercase string
# 'epics' as string of space-separated uppercase epics
read_data () {
echo "Enter Mkt then Stocks & end with xx or hit ^D (or ^C to abort)"
echo "US = us; UK = uk; Canada = ca; Venture exchge = v"
read_until market
[ -z "$market" ] && echo "no market supplied" 1>&2 && exit 1
read_while epics
[ -z "$epics" ] && echo "no epics supplied" 1>&2 && exit 1
market=`echo $market | tr 'A-Z' 'a-z'` #to lower
epics=`echo $epics | tr 'a-z' 'A-Z'` #to upper
}
#Builds a URL from components; sets global 'url'
assemble_url () {
url=$1$2
shift; shift
for i in $*; do
#url+="&$i"
url="$url&$i"
done
}
#Builds a URL for stockcharts
stockcharts_url () {
case $1 in
us)
assemble_url $STOCKCHARTS_URL_BASE s=$2 \
p=D yr=5 mn=0 dy=0 i=t18680472715 r=1503841764277
;;
uk)
assemble_url $STOCKCHARTS_URL_BASE s=$2.L \
p=D yr=5 mn=0 dy=0 i=t40345613568 r=1503767028109
;;
ca)
assemble_url $STOCKCHARTS_URL_BASE s=$2.TO \
p=D yr=5 mn=0 dy=0 i=t77110325637 r=1503766992765
;;
v)
assemble_url $STOCKCHARTS_URL_BASE s=$2.V \
p=D yr=5 mn=0 dy=0 i=t88088727052 r=1503768309990
;;
*)
echo "unknown market '$1'" 1>&2
exit 1
esac
}
#Start or connect to a running web browser and open a URL in a new tab
#Discard annoying shell error messages from firefox
browse () {
case $BROWSER in
firefox)
browse_firefox --new-tab "$@"
;;
seamonkey)
browse_seamonkey --new-tab "$@"
;;
chrome)
browse_chrome --new-tab "$@"
;;
system)
browse_system --new-tab "$@"
;;
none)
#echo browse: none "$@"
;;
*)
browse_system --new-tab "$@"
;;
esac 2>&1 | grep -v GLib-GObject-CRITICAL | grep -v '^ *$' 1>&2
}
browse_firefox () {
#echo browse: firefox $@ && return
if [ -x /usr/bin/firefox ]; then
/usr/bin/firefox $FIREFOX_PROFILE "$@"
return
fi
#try user's path
firefox $FIREFOX_PROFILE "$@"
}
browse_seamonkey () {
#echo browse: seamonkey $@ && return
#try to find seamonkey or mozilla in likely places
if [ -x /usr/local/bin/mozilla ]; then
/usr/local/bin/mozilla $FIREFOX_PROFILE "$@"
return
fi
if [ -x /usr/local/bin/seamonkey ]; then
/usr/local/bin/seamonkey $FIREFOX_PROFILE "$@"
return
fi
#try user's path
mozilla $FIREFOX_PROFILE "$@" > /dev/null 2>&1 || seamonkey $FIREFOX_PROFILE "$@"
}
browse_chrome () {
#echo browse: chrome $@ && return
if [ -x /usr/bin/google-chrome ]; then
/usr/bin/google-chrome "$@"
return
fi
#try user's path
google-chrome "$@"
}
browse_system () {
#echo browse: system $@ && return
if [ -x /usr/local/bin/defaultbrowser ]; then
/usr/local/bin/defaultbrowser "$@" #puppy linux
return
fi
if [ -x /usr/bin/x-www-browser ]; then
/usr/bin/x-www-browser "$@" #ubuntu
return
fi
}
###########################################################################
# main
###########################################################################
read_data
[ -z "$market" ] && echo "no market supplied" 1>&2 && exit 1
[ -z "$epics" ] && echo "no epics supplied" 1>&2 && exit 1
echo "market: $market"
echo "epics: $epics"
#iterate over the epics, build a URL, and invoke a browser in the background
for epic in $epics; do
stockcharts_url $market $epic
echo "url: $url"
browse $url &
sleep $BROWSER_DELAY
done
exit 0
###########################################################################
-
- Posts: 28
- Joined: November 10th, 2016, 12:49 am
Re: Bash script to display a series of graphs on different tabs
Breelander wrote: You do know that Windows 10 has been able to run native Linux apps/commands for over a year now?
http://dilbert.com/strip/1995-06-24
![Very Happy :D](./images/smilies/icon_e_biggrin.gif)
-
- Posts: 28
- Joined: November 10th, 2016, 12:49 am
Re: Bash script to display a series of graphs on different tabs
I just noticed there are still at least a couple of lines in the script that won't make it through a classic 'sh'. The two declarations "local line" need to be removed from read_until() and read_while(). On my Mint/Ubuntu machine, 'sh' is a symlink to 'dash' (?), and on the latest Puppy (similar to the OP's but newer) it's to 'bash', so it's hard to test...1nv35t wrote: Thanks. Useful for those of us who prefer Unix over Linux (and its systemD direction tendencies/consequences).
OpenBSD here (no bash).
Re: systemd. I'll try OpenBSD - Linux has become bloated and inscrutable just like Windows. I really hope that the Devuan splitters get traction.
-
- Lemon Quarter
- Posts: 2743
- Joined: November 4th, 2016, 11:12 am
Re: Bash script to display a series of graphs on different tabs
Coincidence, I've decided to give FreeBSD a go and re-read your comments here yesterday:1nv35t wrote:Thanks. Useful for those of us who prefer Unix over Linux (and its systemD direction tendencies/consequences).desmid wrote:I've changed the script to use the lowest common denominator syntax: rather than 'bash', it's now just good old Bourne shell, 'sh', so that should work with any bash (Bourne Again SHell) as well as with other sh inplementations (dash, busybox).
OpenBSD here (no bash).
https://www.lemonfool.co.uk/viewtopic.p ... bsd#p68731
So, have you exchanged FreeBSD for OpenBSD? And why?
Apologies for drifting off-topic.
RC
-
- Lemon Pip
- Posts: 71
- Joined: November 30th, 2017, 11:14 am
Re: Bash script to display a series of graphs on different tabs
Hi Desmid thanks for v3 ................. it works!
I see the latest version of Chrome doesn't allow tab wheel scrolling! This feature is very useful if you have 15 tabs open
Stockcharts is the only site (afaiaa) that does ratio charts and p&f charts
The script works fine for ratios ie enter PRU.L:SLA.L as the epic in the url
I haven't got round to p&f yet
I see the latest version of Chrome doesn't allow tab wheel scrolling! This feature is very useful if you have 15 tabs open
Stockcharts is the only site (afaiaa) that does ratio charts and p&f charts
The script works fine for ratios ie enter PRU.L:SLA.L as the epic in the url
I haven't got round to p&f yet
-
- Lemon Pip
- Posts: 71
- Joined: November 30th, 2017, 11:14 am
Re: Bash script to display a series of graphs on different tabs
The pru.l:sla.l example is not very good
A better one is INTC:MU which plots the ratio of the 2 share prices and answers the qu Has intel outperformed micron?
http://www.stockcharts.com/c-sc/sc?s=IN ... 3841764277
The i option in the url has encoded the info for the type of chart - this one gives a line with no ma's etc I haven't figured out what the r option does
A better one is INTC:MU which plots the ratio of the 2 share prices and answers the qu Has intel outperformed micron?
http://www.stockcharts.com/c-sc/sc?s=IN ... 3841764277
The i option in the url has encoded the info for the type of chart - this one gives a line with no ma's etc I haven't figured out what the r option does