Have you tried ssh user@cdot "set -unit GB ; your_command_here"?

--tmac

Tim McCarthy
Principal Consultant



On Thu, May 14, 2015 at 10:49 AM, Basil <basilberntsen@gmail.com> wrote:
I'm trying to use CDOT noninteractively from bash, but running into trouble. Let's say for example you wanted to get a list of volumes on an SVM and then sort by size- there's no sort in the interactive CLI and it asks you to enter text every page of results, so my initial thought was to send the command noninteractively and do what I need done in bash. If you send the command "ssh user@nas volume show -vserver whatever", you get a nicely formatted table without any of the line-splitting, confirmations, or other interactive shell nonsense:

Vserver   Volume       Aggregate    State      Type       Size  Available Used%
--------- ------------ ------------ ---------- ---- ---------- ---------- -----
svm vol1 aggr1 online    RW          2TB     2.00TB    0%
svm vol2 aggr1 online    RW          100GB     100.00GB    0%

This is much better, but I still can't use the size field to sort unless I can change it all to the same unit. If this were an interactive session, I'd use "set -units GB", however it's not. How can I accomplish that non-interactively? Can I send multiple commands in one ssh command?

One thing that should work but doesn't is creating a list of commands that will run and sending them via ssh- 

me@myserver:/home/me $ cat temp
set -units KB
volume show -vserver svm -volume *root
me@myserver:/home/me $ ssh admin@nas < temp
Pseudo-terminal will not be allocated because stdin is not a terminal.
nas::> set -units KB

nas::> volume show -vserver svm -volume *root
Vserver   Volume       Aggregate    State      Type       Size  Available Used%
--------- ------------ ------------ ---------- ---- ---------- ---------- -----
svm
          svm_root
                       aggr1     online     RW    1048576KB   995796KB    5%

nas::>

me@myserver:/home/me $

As you see, as soon as it detects multiple lines, it switches back to the interactive shell. If I had use something with more than a single line of output, it would have given me a couple of lines, asked for "confirmation", and then exited. All the while putting "readability" whitespace inconsistently all over the results.

Any ideas?

Basil

_______________________________________________
Toasters mailing list
Toasters@teaparty.net
http://www.teaparty.net/mailman/listinfo/toasters