sduser1
asked on
Help with running batch script
I am trying to get the version of the chrome using the below bash script.
#!/bin/bash
getChrome() {
if [ -z "$1" ]; then
echo -e "No arguments specified\n"
echo -e "Options:
--version Displays the version of the chrome
--location Displays the location of the chrome profile folder.
version Displays the version of the chrome
location Displays the location of the chrome profile folder.
return 0
fi
if [[ $1 == version]]; then
google-chrome --version
echo 'test'
return 0
fi
if [[ $1 == location]]; then
chromeLocation = ""/Users/user1/Library/App lication Support/Google/Chrome/Defa ult"
return 0
fi
}
export -f getChrome
when i run the command in the bash terminal getChrome --version, it is not printing the version. Please help.
#!/bin/bash
getChrome() {
if [ -z "$1" ]; then
echo -e "No arguments specified\n"
echo -e "Options:
--version Displays the version of the chrome
--location Displays the location of the chrome profile folder.
version Displays the version of the chrome
location Displays the location of the chrome profile folder.
return 0
fi
if [[ $1 == version]]; then
google-chrome --version
echo 'test'
return 0
fi
if [[ $1 == location]]; then
chromeLocation = ""/Users/user1/Library/App
return 0
fi
}
export -f getChrome
when i run the command in the bash terminal getChrome --version, it is not printing the version. Please help.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Question:
Do you know the command that is used to get the chrome version in linux OS?
i got the below for mac and it worked fine.
/Applications/Google\ Chrome.app/Contents/MacOS/ Google\ Chrome --version
Thanks
Do you know the command that is used to get the chrome version in linux OS?
i got the below for mac and it worked fine.
/Applications/Google\ Chrome.app/Contents/MacOS/
Thanks
you are checking for "version" rather than "--version"
use
if [[ "X$1" == X--version]]
or rather a case/esac statement
use
if [[ "X$1" == X--version]]
or rather a case/esac statement
@sduser1
If using windows
a)
we can view the same using:
C:\Windows\regedit.exe
HKEY_CURRENT_USER
Software
Google
Chrome
BLBeacon
value of "version"
b)
Same thing using bash.exe at Windows:
CHROME_VERSION=$(/cygdrive /c/Windows /System32/ reg.exe QUERY "HKEY_CURRENT_USER\Softwar e\Google\C hrome\BLBe acon" /v version | /usr/bin/awk '"version" == $1 { print $NF}')
echo $CHROME_VERSION
OR
/cygdrive/c/Windows/System 32/reg.exe QUERY "HKEY_CURRENT_USER\Softwar e\Google\C hrome\BLBe acon" /v version | /usr/bin/awk '"version" == $1 { print $NF}'
OR
echo $(/cygdrive/c/Windows/Syst em32/reg.e xe QUERY "HKEY_CURRENT_USER\Softwar e\Google\C hrome\BLBe acon" /v version | /usr/bin/awk '"version" == $1 { print $NF}')
OR
/cygdrive/c/Windows/System 32/reg.exe QUERY "HKEY_CURRENT_USER\Softwar e\Google\C hrome\BLBe acon" | /usr/bin/awk '"version" == $1 { print $NF}'
OR inside C:\Windows\System32\cmd.ex e
C:\Windows\System32\wbem\W MIC.exe datafile where name="C:\\PROGRA~2\\Google \\Chrome\\ Applic~1\\ chrome.exe " get Version /value
If using windows
a)
we can view the same using:
C:\Windows\regedit.exe
HKEY_CURRENT_USER
Software
Chrome
BLBeacon
value of "version"
b)
Same thing using bash.exe at Windows:
CHROME_VERSION=$(/cygdrive
echo $CHROME_VERSION
OR
/cygdrive/c/Windows/System
OR
echo $(/cygdrive/c/Windows/Syst
OR
/cygdrive/c/Windows/System
OR inside C:\Windows\System32\cmd.ex
C:\Windows\System32\wbem\W
am i crazy or was the question edited ???
"-version" was changed to "--version" in the command line
the test line was edited so the test string dis not start with a "-". it will still break if the user provides one, btw.
"-version" was changed to "--version" in the command line
the test line was edited so the test string dis not start with a "-". it will still break if the user provides one, btw.
@sduser1, You're welcome!
Good luck!
Good luck!
ASKER
if [[ $1 == version]]; then
/Applications/Google\ Chrome.app/Contents/MacOS/
echo 'test'
return 0
fi