HPE Storage Users Group
https://3parug.net/

how to redirect the result of a CLI command to a file
https://3parug.net/viewtopic.php?f=18&t=592
Page 1 of 1

Author:  ader [ Fri Feb 14, 2014 7:07 am ]
Post subject:  how to redirect the result of a CLI command to a file

hello,

could you help me on WINDWOS CLI

I want to know how to redirect the result of a CLI command to a file
For exemple:


3par1 cli% showvv
------Rsvd(MB)------- --(MB)--
Id Name Prov Type CopyOf BsId Rd -Detailed_State- Adm Snp Usr VSize
1 .srdata full base --- 1 RW normal 0 0 81920 81920
0 admin full base --- 0 RW normal 0 0 10240 10240

regards,

Author:  eve [ Fri Feb 14, 2014 7:15 am ]
Post subject:  Re: how to redirect the result of a CLI command to a file

Why not run the commands from Interactive CLI on the SP ?
Use Putty and log output to a text file
(logging -> click printable output - select were to store file & name (tips change extention to .txt)

ready

Author:  ader [ Fri Feb 14, 2014 7:54 am ]
Post subject:  Re: how to redirect the result of a CLI command to a file

thanks for your reply

I know, but just out of curiosity it's possible or not.

Author:  hdtvguy [ Fri Feb 14, 2014 12:30 pm ]
Post subject:  Re: how to redirect the result of a CLI command to a file

I do it all the time and from batch files and Powershell so that I can then read in the results and parse it and act on what I find. The trick is run it from a command prompt, the CLI just loads a shell for you, forget that, not needed.

Here is a simple scrip that I run to output volumes that meet a search name. It pumps the data to a file using the CLI

Designed for 2 arrays, substitute xxxx and yyyy for your array names and password files.

I have script that will enumerate VMs on datastores, snap the VM then snap the array volume, others that will shutdown a VM and run an updateVV to refresh RDMs then power the VM back on. The CLI is very powerful. The only caution is the CLI does not return errors they way you would expect. Most CLI commands only retrun a non-zero error code if the command itself is incorrect. If you want to check the success of the actual command you need to script outputting the anticipated changes and scan code that with code to make sue the array did what you want. Also note that CLI commands are not alsway consistent from version to version as the CLI was not intended for scripting. There go forward scripting API is the web APIs winch I disagree with. Many administrators can write batch/scrip files, but writing xml/html is a different league.





@echo off
REM ======================================================================
REM update the LOCALARRAY and LOCALPWFILE varibale with the local array name and password file
REM update the REMOTEARRAY and REMOTEPWFILE variables with the remote array and password file
REM
REM
REM ======================================================================
ECHO OFF
setlocal enableextensions enabledelayedexpansion

set LOCALARRAY=xxxx
set LOCALPWFILE=xxxx_admin.pwfile
set REMOTEARRAY=yyyy
set REMOTEPWFILE=yyyy_admin.pwfile


echo.
echo This will report on vv sets for the supplied system on both arrays
echo.

set /p lparname=What is the search name volumes you want to show?

if exist !lparname!.txt del !lparname!.txt /Q



set TPDSYSNAME=!REMOTEARRAY!
set TPDPWFILE=!REMOTEPWFILE!
echo.
echo.
echo The following info is for !REMOTEARRAY!:
echo.

echo Search name: !lparname!
echo.
call showvv -showcols Name,VV_WWN,VSize_MB,Comment -sortcol 0 *!lparname!*
echo Information for yyyy: >>!lparname!.txt
echo Volume name: !vvsname! >> !lparname!.txt
call showvv -showcols Name,VV_WWN,VSize_MB,Comment -sortcol 0 *!lparname!* >> !lparname!.txt

set TPDSYSNAME=!LOCALARRAY!
set TPDPWFILE=!LOCALPWFILE!
echo.
echo The following info is for !LOCALARRAY!:
echo.
echo Search name: !lparname!
echo.
call showvv -showcols Name,VV_WWN,VSize_MB,Comment -sortcol 0 *!lparname!*
echo Information for xxxx: >> !lparname!.txt
echo Volume name: !vvsname! >> !lparname!.txt
call showvv -showcols Name,VV_WWN,VSize_MB,Comment -sortcol 0 *!lparname!* >> !lparname!.txt

echo.
echo Information has also been saved in file: !lparname!.txt


GOTO FINISH

rem --------------------- subroutines --------------
:choice

set /a done=0
set /P answer=!ask!
if /i "!answer!"=="Y" goto :EOF
if /i "!answer!"=="N" (
set /a done=1
exit /b
)
goto choice

GOTO :EOF


GOTO :EOF

:ERROR_HANDLER
echo.
echo ...Error occured...
echo.
echo. CNTRL-C to break out and resolve issue and clean up what has been created.
echo.
pause
pause
exit

:FINISH
echo.
echo Thanks for playing...
exit /b

Author:  Richard Siemers [ Sat Feb 15, 2014 3:21 am ]
Post subject:  Re: how to redirect the result of a CLI command to a file

ader wrote:
I want to know how to redirect the result of a CLI command to a file


For windows, > will send the output to a file, overwriting the file. double >> will append to the file.

So:

showvv > output.txt
or
showvv >> output.txt

Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/