java netapp.cmds.jsh

One of the problems I have with the NetApp filers is the inability to use simple UNIX commands like cp (copy) and mv (move) even though their base OS is Linux. Often times I have needed to use these commands to make backup copies of files I need to modify but have not been able to. There are a number of ways to get around this problem:

  • export and mount /vol/vol0 to a UNIX host and use native UNIX commands
  • CIFS share /vol/vol0 to a Windows host and use Native windows commands
  • create a snapshot of /vol/vol0 and use the Data ONTAP native rdfile and wrfile command

Of course there are problems with these as well.

  • In order to make use of exporting and mounting the volume I would require access to a UNIX host with the appropriate permissions to perform these actions; which often enough I do not have access to.
  • In order to use a CIFS share the filer needs to have a CIFS license in place and have access to a windows system that has access to the filer; and at least one of my filers does not have a CIFS license, and on the ones that do I may not have access to a system that can map the CIFS share on the given network.
  • the Data ONTAP rdfile and wrfile commands are useful, but dangerous. wrfile, which allows you to write to a file, first destroys the file (removes all data from it) then opens it for you to add to. This means if you forget to use rdfile first to see the contents of the file, then you have just erased the file. Correcting this can be as simple as pulling the original file from a snapshot (if you remembered to take one) or as complicated as needing to create the file from scratch.

The solution to all these problems is to use an undocumented java shell on the filer which grants the ability to use cp, mv and other commands.

Here is an example of the command to drop to the java shell and a list of the commands available:

filer01>java netapp.cmds.jsh
jsh> ?
Java Shell commands:
cd [directory]
pwd
ls [-l]
cat file
rm file [file2 …]
cp src dest
mv src dest
ps [-l]
kill <-1|-9> threadName
gc
classpath [pathname]
syspath [pathname]
Debug on|off
threads
monitors
heap
version
syncdb
du [-sk] [files or directories]
java_class [&]
ONTAP_cmd
jsh> exit
filer01>

This command alone has made this class worth it for me, this will come in very handy in the future.