ONTAP Discussions

Priv Set Advanced in a shell script

os2mac
6,796 Views

I'm trying to run a manual quota report with specific parameters from a Unix box against a cDot 8.2 svm.

 

basically I want to go to advanced mode: 

 

set -privilege advanced -confirmations off -units KB -rows 99 -showseparator "\,"

 

and then run 

 

quota report -vserver svmservername -fields quota-type,quota-target-id,volume,tree,disk-used,disk-limit,threshold,quota-specifier

 

it works when I do it manually but not when I run the following script:

 

#!/usr/bin/bash
#Command Variables
USER="username"
SET='set -privilege advanced -confirmations off -units KB -rows 99 -showseparator "\,"'
REPORT=`quota report -vserver svmservername -fields quota-type,quota-target-id,volume,tree,disk-used,disk-limit,threshold,quota-specifier`
OUT=quota.txt

SVMSVR=192.168.1.1


case $1 in
'SVMSVR')
ssh $USER@$SVMSVR "$SET; $REPORT" >quota.txt
;;
*)
esac
exit

 

what am I doing wrong?

 

please don't suggest I do this in a powershell script. this must be run from a unix box.

 

4 REPLIES 4

SeanHatfield
6,648 Views

try it without the back ticks.

 

If this post resolved your issue, help others by selecting ACCEPT AS SOLUTION or adding a KUDO.

os2mac
6,611 Views

I did several times and it several different ways..

 

I've discovered after hours of frustration, trial and error that the output for an ssh session is just not the same is the output of logging in and running the commands manually.

 

I've managed to hack it but it would be VERY handy if netapp were able to make this output standard across both methods.

 

thanks for your response though.

 

SeanHatfield
6,604 Views

Glad you got it working.  The output should be the same.  Perhaps you're still running your local quota command?

 

What I was trying to nudge you towards was that using back ticks on the quota command is executing it against your local machine and storing the result in the variable.  Then later you were trying to send the result of the local quota command to the cluster over ssh.  You probably also discovered you need quotes around the IP, and the case structure doesn't look right.  you probably want a for/in/do structure there instead if you plan to have a list of targets to run it against at some point down the road.

 

 

 

If this post resolved your issue, help others by selecting ACCEPT AS SOLUTION or adding a KUDO.

bobshouseofcards
6,580 Views

os2mac -

 

I'm with Sean - there shouldn't be any difference between running a command via SSH or via a direct login to the CLI.  I use SSH (well, Plink from Windows) for tons of scripted stuff where a command line is just convenient.

 

Another suggestion for improvement - use "rows 0" rather than "rows 99".  Setting rows to 99 can still paginate if enough data, while rows 0 will not.

 

And since you mention this has to come from a UNIX box - just have to ask - how's your perl?  If you have decent perl skills, there are additional options to get just the data you need and format as desired using the NMSDK alongside perl in functionally small scripts and you don't need to worry about setting options and such to get the data.  Just a thought for your consideration.

 

 

Hope this helps.

 

Bob Greenwald

Senior System Engineer | cStor

NCIE SAN ONTAP, Data Protection

 

cStorFullLogo_web.png

 

 

Kudos and accepted solutions are always appreciated.

Public