Subscribe
Accepted Solution

Running 400 commands within the commandline

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

Re: Running 400 commands within the commandline

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

Re: Running 400 commands within the commandline

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".

Re: Running 400 commands within the commandline

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

Re: Running 400 commands within the commandline

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.

Re: Running 400 commands within the commandline

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.

Re: Running 400 commands within the commandline

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

Re: Running 400 commands within the commandline

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

Re: Running 400 commands within the commandline

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

Re: Running 400 commands within the commandline

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