ONTAP Discussions

Running 400 commands within the commandline

highvailsys
12,442 Views

Hey guys,

This might be a stupid question, but I have list of 300+ commands that I need to run in the command line in sequence, either via SSH or Telnet.  I need to move data from a volume with 150 subfolders into a volume with 150 qtrees so that we can do qtree quotas.  The commands will be standard ontap commands such as create qtrees and then moving the data from one subfolder to another subfolder using ndmpcopy.  Any suggestions?

From my understanding, you can't run a script on the Netapp itself, and I'm a windows guy so suggesting that I code some python or perl is akin to selling a fish some water.

Thank you for any suggestions.


Chris

1 ACCEPTED SOLUTION

columbus_admin
12,439 Views

Hi Chris,

     How much data are you moving?  It may be simpler from a Windows standpoint to batch it all up and copy it from a host that has access to the volume.  You could still batch it and simply paste the ndmpcopy lines directly into the filer console...

if you were to type out the following and copy and paste them into the filer console, it will process them one at a time.

qtree create /vol/volume/qtree1

qtree create /vol/volume/qtree2

qtree create /vol/volume/qtree3

Keep in mind, if you want the qtree names to be the same as the folders, you have two renames...rename the old folder from subfolder to subfolder_old and then the qtree from subfolder_new to subfolder.

You can do your qtree create with a simple batch file from a concatenated Excel dump.  Run "dir /ad /b" from a Windows host with access to get the folder and edit out any not being "moved".

View solution in original post

11 REPLIES 11

roman_verysell
12,375 Views

You can use a rsh (remote shell), and some host-based script tool for it.

columbus_admin
12,440 Views

Hi Chris,

     How much data are you moving?  It may be simpler from a Windows standpoint to batch it all up and copy it from a host that has access to the volume.  You could still batch it and simply paste the ndmpcopy lines directly into the filer console...

if you were to type out the following and copy and paste them into the filer console, it will process them one at a time.

qtree create /vol/volume/qtree1

qtree create /vol/volume/qtree2

qtree create /vol/volume/qtree3

Keep in mind, if you want the qtree names to be the same as the folders, you have two renames...rename the old folder from subfolder to subfolder_old and then the qtree from subfolder_new to subfolder.

You can do your qtree create with a simple batch file from a concatenated Excel dump.  Run "dir /ad /b" from a Windows host with access to get the folder and edit out any not being "moved".

lagenevoise
12,375 Views

I Chris,

For qtree creation I think the best solution is the NetApp SDK with perl

qtree-create
Create a new  qtree.
Input NameRangeTypeDescription
mode
string
optional
The file permission bits of the qtree. Similar to  UNIX permission bits: 0755 gives read/write/execute permissions to owner and  read/execute to group and other users. It consists of 4 octal digits derived by  adding up bits 4, 2, and 1. Omitted digits are assumed to be zeros. First digit  selects the set user ID (4), set group ID (2), and sticky (1) attributes. The  second digit selects permissions for the owner of the file: read (4), write (2),  and execute (1); the third selects permissions for other users in the same  group; the fourth for other users not in the group. If this argument is missing,  use the default value specified in the option "wafl.default_qtree_mode".
qtree
string
The path of the qtree, relative to the volume.
volume
string
Name of the volume on which to create the qtree

For data reallocation I think plink.exe should be help you. with several cmd scripts as launchers

http://ss64.com/nt/for_cmd.html

A sample with ping all computers in the file sd.txt

@echo off
FOR /F "usebackq" %%I IN (sd.txt) DO (
PING -n 1 -w 100 %%I
IF !ErrorLevel! == 0 shutdown -s -m \\%%I -t 60 -c "Epic fail"
)

Regards

Christophe

aborzenkov
12,375 Views

You can use limited scripting on NetApp; see “source” command. So you could create script, place it on NetApp and execute there; it is probably faster than executing 400 commands using remote API/ssh one by one.

datamanaged
12,375 Views

Hi Chris,

As a side note (probably don't want to do this with 400 commands), you can run multiple commands in sequence on the CLI by seperating them with a semi-colon. If you had smaller groups of commands, this would probably be the easiest route.

Best Regards,

Adam S.

highvailsys
12,375 Views

Hey guys,

thanks for the suggestions, very helpful.  In the end I'm going create the commands in Excel using a mix of the dir /ad /b and the =concatenate formula and then copy and paste them into the telnet session.  Didn't realize you could do that and have them execute sequentially.

Thanks again!

Chris

BrendonHiggins
12,375 Views

I use the Excel method and find this way best.

Create commands in Excel using Excel's tools to auto complete etc

Copy the commands from Excel into notpad

Remove extra tabs, spaces and 'crap' using notepads find, replace feature

Save the commands to show what I was trying to do later or repeat the process- Never know when it may be required.

Use a putty session to connect via telnet to the filer

Ensure putty is recording to a log file what has happened - VERY USEFUL

    - Configure putty with "c:\puttylogs\log-&h-&y&m&d-&t.log" and it will always record logs - Great for finding out what happened after a disaster, etc

Paste the commands from notepad into putty session and sit back and watch.

   - To limit the time the console is in use or scope for the job to go wrong, I like to copy / paste about 50 commands at a time and just work my way down the notepad list.

   - If the command/s will take a long time to run, you may think about running them as RSH commands.  This will enable you to access the console if required.

Hope this helps

Bren

Darkstar
12,374 Views

All answers given here are valid options. BUT:

Whatever you do, please DON'T try being smart and doing a copy/paste of all these commands into a PuTTY session (or any other SSH session for that matter).

I did that once and it crashed the filer

I guess the NetApp has only a limited input buffer for SSH commands so you should not send more than, say, 10 commands or so via copy/paste. Wait for the prompt to come back and then send the next 10. And so on. Or use any other way outlined in the above posts.

-Michael

highvailsys
12,374 Views

Hey,

How long ago did that crash the filer?  I've done about 30 commands at once so far and no problems, but may reduce that some just to be safe.  Maybe it was a bug with an older version of ontap?  I'm hoping so!

I also saw your response to the group IDs in AD, nice answer, makes sense why they wouldn't implement that.


Thanks,


Chris

Darkstar
9,169 Views

True, that was some time ago. I don't know which OnTap version it was though.

But I also had problems on newer versions, like come commands at the end of the clipboard got cut off or were lost completely, so I'd double-check that all commands you pasted are actually executed and nothing got lost

-Michael

columbus_admin
9,169 Views

If you are on Windows, I know there is such an issue using Putty.  However from a Linux workstation, I can paste much longer commands into an SSH session.

Testing with RBAC, I created multiple roles to assign to a group because it would truncate everytime I tried to paste the complete line.  I dumbly went and created multiple roles with each permission set, and assigned them to the group.  Then found out two days later, if I had used Linux, I could have pasted them all into a single line and had a single role...oh well.

- Scott

Public