-
1. Re: NSH Script unable to find OS Type
Santhosh Kurimilla Dec 28, 2017 9:25 PM (in response to vijay Chaudhery)Use nover or agentinfo command.
Below uname command through nexec, requires cmd /c for Windows. But, your script is to identify the OS.
nexec $server cmd /c uname
Thanks,
Santhosh Kurimilla
BlackBerry# 7995072904
-
2. Re: NSH Script unable to find OS Type
Matthew Ragland Dec 29, 2017 8:46 AM (in response to Santhosh Kurimilla)Using cmd /c is reserved for Windows systems:
nexec $SERVER cmd /c uname
/bin/bash: cmd: command not found
if you want it to work on linux systems do the following:
nexec $SERVER sh -c "uname -s"
Linux
-
3. Re: NSH Script unable to find OS Type
vijay Chaudhery Dec 29, 2017 10:33 AM (in response to vijay Chaudhery)Thanks for the reply, i tried all getting below error
server1% OSTYPE="$(uname -D //${server} -s)"
server1% echo $OSTYPE
WindowsNT
server1% nexec $server cmd /c uname
'uname' is not recognized as an internal or external command,
operable program or batch file.
server1% nexec $server uname -s
The system cannot find the file specified.
server1% nexec $server sh -c "uname"
The system cannot find the file specified.
server1%
-
4. Re: NSH Script unable to find OS Type
Matthew Ragland Dec 30, 2017 8:37 AM (in response to vijay Chaudhery)I'm going to pretend to be Bill Robinson for a minute, and ask what exactly are you trying to accomplish here? What is your desired outcome? Why aren't you using the server property value for OS?
-
5. Re: NSH Script unable to find OS Type
vijay Chaudhery Jan 2, 2018 11:27 AM (in response to vijay Chaudhery)Hi Matthew, I am looking out to get the OS Type for my nsh script for this i tried the above option with does not work for me can you please let me know how to use the property value to get the OS type?
Trying with the below command but getting error
server1% blcli_execute PropertyInstance getPropertyValue "Class://SystemObject/Server" "OS"
Command execution failed. com.bladelogic.om.infra.mfw.util.NotFoundException: Instance with path Class://SystemObject/Server was not found
-
6. Re: NSH Script unable to find OS Type
Matthew Ragland Jan 2, 2018 2:29 PM (in response to vijay Chaudhery) -
7. Re: NSH Script unable to find OS Type
vijay Chaudhery Jan 3, 2018 2:01 PM (in response to vijay Chaudhery)My apologies , i did not get how to use this parameter? i can use this type 1 script not sure how to use this with calling a group
GROUP1="/Server/mygroup"
TOT_SRVS=`blcli Server listServersInGroup "$GROUP1"`
OS=$2
for server in $TOT_SRVS
do
#OS="$(nexec $server uname -s)"
echo $OS
echo "servername :$server and OS Type : $OS" >> $output_file
done
-
8. Re: NSH Script unable to find OS Type
Bill RobinsonJan 4, 2018 7:49 AM (in response to vijay Chaudhery)
GROUP1="/Server/mygroup"
TOT_SRVS=`blcli Server listServersInGroup "$GROUP1"`
OS=$2
for server in $TOT_SRVS
do
#OS="$(nexec $server uname -s)"
echo $OS
echo "servername :$server and OS Type : $OS" >> $output_file
done
so that's kind of ok but there are some problems w/ it.
first - why are you doing this ? why do you need to write the server:os to a file? what are you going to do w/ that ?
so let's fix your script snippet above:
# unless you have a top level folder in the Servers workspace named 'Server' you don't include '/Server' in the group path.
GROUP1="/mygroup"
# why are you taking OS as an argument if that's what you are trying to derrive ? so we'll take that out.
# you are not using the blcli very well here
blcli_execute Server listServersInGroup "${GROUP1}"
blcli_storeenv TOT_SRVS
# it's better habbit to use a while loop instead of a 'for' so you can handle spaces, etc.
while read server
do
# why did you comment out the uname call ?
OS="$(uname -D //${server} -s)"
echo "servername: ${server} and OS Type: ${OS}" >> "${output_file}"
# strip the trailing empty line from the list of servers
done <<< "$(awk 'NF' <<< "${TOT_SRVS}")"
matt's example is using a job to pass in the server name and the value of the server property. that works if you are running this as a nsh job. it's unclear if you are doing that or running this as a script from the command line. instead of the uname call you could also run a blcli command to get the value of 'OS'. that has the advantage of not needing nsh access to the targets. if you are running this from the command line on some workstation that may be a problem. this version of the script would look like:
GROUP1="/mygroup"
blcli_execute Server listServersInGroup "${GROUP1}"
blcli_storeenv TOT_SRVS
while read server
do
blcli_execute Server printPropertyValue ${server} "OS"
blcli_storeenv OS
echo "servername: ${server} and OS Type: ${OS}" >> "${output_file}"
done <<< "$(awk 'NF' <<< "${TOT_SRVS}")"
now, that could be slow depending if you have a lot of servers in the group. so instead you could use a bulk dump of the property value:
GROUP1="/mygroup"
blcli_execute Server listServersInGroup "${GROUP1}"
blcli_storeenv TOT_SRVS
awk 'NF {print $1",OS"}' <<< "${TOT_SRVS}" > "/tmp/get.csv"
blcli_execute Server getBulkServerPropertyValuesAndLogResults "/tmp" "get.csv"
# results will be in /tmp/get_results.csv
-
9. Re: NSH Script unable to find OS Type
Bill RobinsonJan 4, 2018 7:53 AM (in response to Santhosh Kurimilla)
uname is not a native windows command so your 'nexec cmd /c uname' won't work.