SydroCmd Befehle: Unterschied zwischen den Versionen

Aus TALSIM Docs
Keine Bearbeitungszusammenfassung
(update with content from internal wiki http://srvvm-wiki/wiki/index.php?title=SydroCmd&oldid=1770)
Zeile 1: Zeile 1:
{{Navigation|vorher=SydroCmd-Verzeichnisstruktur und Dateien|hoch=Arbeiten mit dem SydroCmd tool|nachher=Operationeller Einsatz von Talsim-NG}}
{{Navigation|vorher=SydroCmd-Verzeichnisstruktur und Dateien|hoch=Arbeiten mit dem SydroCmd tool|nachher=Operationeller Einsatz von Talsim-NG}}
==Extract==
==Extract==
Extracts strings from each line within an ASCII file.
Extracts strings from each line within an ASCII file.


{| class="wikitable" style="width: 50%;"
{| class=wikitable
!style="width: 10%"|Argument
!Argument !! Description
!style="width: 90%"|Description
|-
|-
|1
|Key || <code>-extract</code>
|<code>-extract</code>
|-
|-
|2
|1 || sourcefile
|sourcefile
|-
|-
|3
|2 || <code>-string</code>: search for a string
|<code>-string</code> or <code>-pos</code> or <code>-split</code> <br />(<code>-string</code>=search for a string, <code>-pos</code>=select a position, <code>-split</code>=delimits the string)
<code>-pos</code>: select a position<br/>
<code>-split</code>: split a string
|-
|-
|4
|3 || either string or position as a number
|either string or position as a number
|-
|-
|5
|4 || <code>-endstring</code>, <code>–endlen</code> or <code>-array</code>
|<code>-endstring</code> or <code>-endlen</code> or <code>-array</code>
|-
|-
|6
|5 || either a string or the word <code>blank</code> or a position as an integer, depending on the previous argument. With <code>-split</code> a comma-separated list of indices is required indicating which items should be saved.
|either a string or the work blank or a position as integer, depending on the previous argument. With <code>-split</code> a comma-separated list of indices is required indicating which items should be saved
|-
|-
|7
|6 || targetfile
|targetfile
|}  
|}


'''Example 1''': extracts a string from each line within d:\temp\abc.txt which follows directly after "val=" and ends at the next blank.


;Example1
<pre>
:extracts a string from each line within <code>d:\temp\abc.txt</code> which follows directly after <code>val=</code> and ends at the next blank.
SydroCmd -extract d:\temp\abc.txt -string val= -endstring blank d:\temp\extract.txt
:<code>SydroCmd -extract d:\temp\abc.txt -string :val= -endstring blank d:\temp\extract.txt</code>
</pre>


;Example 2
'''Example 2''': extracts a string from each line within d:\temp\abc.txt starting from position 15 with a length of 25 characters.  
: extracts a string from each line within d:\temp\abc.txt starting from position 15 with a length of 25 characters.  
:<code>SydroCmd -extract d:\temp\abc.txt -pos 15 -endlen 25 d:\temp\extract.txt</code>


<pre>
SydroCmd -extract d:\temp\abc.txt -pos 15 -endlen 25 d:\temp\extract.txt
</pre>


==Download==
==Download==
Downloads a file with a valid URL to the local memory.
Downloads a file with a valid URL to the local machine.


{| class="wikitable" style="width: 50%;"
{| class=wikitable
!style="width: 10%"|Argument
! Argument !! Description
!style="width: 90%"|Description
|-
|-
|1
|Key || <code>-download</code> or <code>-downloadwget</code> (the latter causes [https://www.gnu.org/software/wget/ wget] to be used for downloading)
|<code>-download</code>
|-
|-
|2
|1||URL (possibly with placeholders like <code>{0}</code>)
|URL (possibly with spaceholders like <code>{0}</code>
|-
|-
|3
|2||Arguments separated by a comma filling the placeholders in the URL
|Arguments separated by a comma filling the spaceholders in the URL
|-
|-
|4
|3 || targetfile
|targetfile
|}
|}


;Example
'''Example:''' Downloads a file from the NOAA data archive. Variables are the year, month, day.
:Downloads a file from the NOAA data archive. Variables are the year, month, day.
 
:<code><nowiki>SydroCmd -download http://nomads.ncdc.noaa.gov/modeldata/cfsv2_forecast_mm_9mon/{0}/{0}{1}/{0}{1}{2}/{0}{1}{2}00/flxf.01.{0}{1}{2}00.{3}{4}.avrg.grib.grb2 2016,12,02,2016,12 D:\temp\tmp.grb2 </nowiki></code>
<pre>
SydroCmd -download http://nomads.ncdc.noaa.gov/modeldata/cfsv2_forecast_mm_9mon/{0}/{0}{1}/{0}{1}{2}/{0}{1}{2}00/flxf.01.{0}{1}{2}00.{3}{4}.avrg.grib.grb2 2016,12,02,2016,12 D:\temp\tmp.grb2
</pre>


==Replace==
==Replace==
Replaces all strings with a new string within a file. Is able to handle current date information.
Replaces all strings with a new string within a file. Is able to handle current date information.


{| class="wikitable" style="width: 50%;"
{| class=wikitable
!style="width: 10%"|Argument
! Argument !! Description
!style="width: 90%"|Description
|-
|-
|1
|Key || <code>-replace</code>
|<code>-replace</code>
|-
|-
|2
|1||sourcefile
|sourcefile
|-
|-
|3
|2||search string or <code>DATE</code>
|string to be searched for (see options)
|-
|-
|4
|3||replace string or a date in the format <code>yyyyMMddHHmm</code> or <code>Now</code>
|Replacement string, string to be inserted (see options)
|-
|-
|5
|4||targetfile (if not given, then sourcefile will be overwritten)
|targetfile (if not given, sourcefile will be overwritten)
|}  
|}
 
===Date replacement===
If the search string is the keyword <code>DATE</code>, dynamic date replacement takes place:
* The replace string must then be a date in the format <code>yyyyMMddHHmm</code> or <code>Now</code>.
* In the sourcefile, the placeholder to be replaced must be given as follows: <code>{DATE|ValidFormatstring|ValidNumber,DateInterval}</code>, where
** ValidFormatstring: a date format string consisting of e.g. yyyy, MM, dd, HH, mm (see [https://docs.microsoft.com/en-us/dotnet/standard/base-types/custom-date-and-time-format-strings here] for more options)
** ValidNumber: 0, +2, -5 or any other integer (adds/subtracts the number of years,  months, days, hours, minutes as given with the number)
** DateIntervall= y, M, d, h, m (is used to add the ValidNumber to the date)
:Example: <code>{DATE|dd|+1,d}</code> with a replace date of 30/12/2017 results in <code>31</code> (given date + 1 day, expressed as date (<code>dd</code>)).
 
===Examples===
'''Example 1''': simple replacement of "hello" with "goodbye". The sourcefile will be overwritten.
<pre>
SydroCmd –replace d:\temp\abc.txt hello goodbye
</pre>
 
'''Example 2''': with date information
 
In this  example the first argument is the keyword <code>DATE</code> indicating that date information is used. If this string is found it will be replaced by the date given in the next argument (here 5/12/2016 00:00). In the file abc.txt the variable to be replaced  must be given as follows: <code>{DATE|yyyy|+1,y}</code>. This means the result will be <code>2017</code>, one year added to 2016.


===Options===
<pre>
;2. Argument
SydroCmd –replace d:\temp\abc.txt DATE 201612050000 d:\temp\abcnew.txt
: String to be searched for that will be replaced
</pre>
: Format= <code>[KEYWORD|Valid Formatstring|Valid Number,DateInterval} </code>
::<code>KEYWORD = DATE</code>
::<code>Valid Formatstring</code> = possible is <code>yyy</code>, <code>MM</code>, <code>dd</code>, <code>mm</code>
::<code>Valid Number</code>= <code>0, +2, -5</code> or any other integer (adds/subtracts the number of years, months, days, hours, minutes as given with the number)
::<code>DateIntervall</code>= <code>y, M, d, h, m</code> (is used to add the <code>valid number</code> to the date)
:Example: <code>{DATE|dd|+1,d}</code> with a date 30/12/2017 results in 31


;3. Argument
'''Example 2''': with date information using <code>Now</code>
: ordinary string or in combination with <code>DATE</code> a date in the format <code>yyyyMMDDhhmm</code> or the keyword <code>Now</code>


===Examples===
In this example the first argument is the keyword <code>DATE</code> indicating that date information is used. If this string is found it will be replaced by the date given in the next argument (here the keyword <code>Now</code>). In the file abc.txt the variable to be replaced must be given  as follows: <code>{DATE|yyyyMMdd|+1,M}</code>. This means the result will be the current date plus one month.
;Example1
:simple with “hallo” replaced by “goodbye”. The sourcefile will be overwritten.
:<code>SydroCmd -replace d:\temp\abc.txt hallo goodbye </code>


;Example2
<pre>
:with date information
SydroCmd –replace d:\temp\abc.txt DATE Now d:\temp\abcnew.txt
:<code>SydroCmd -replace d:\temp\abc.txt DATE 201612050000 d:\temp\abcnew.txt</code>
</pre>
:In this example the first argument is <code>DATE</code> indicating that date information is used. If this string is found it will be replaced by the date given in the next argument (here <code>5/12/2016 00:00</code>). In the <code>abc.txt</code> the variable to be replaced must be given as follows: <code>{DATE|yyyy|+1,y}</code>. This means the result will be ‘2017’, one year added to 2016.


==Zip==
==Zip==
Zips files into a Zip File Format.
Compress files to a zip file.


{| class="wikitable" style="width: 50%;"
{| class=wikitable  
!style="width: 10%"|Argument
! Argument !! Description
!style="width: 90%"|Description
|-
|-
|1
|Key || <code>-zip</code>
|<code>-zip</code>
|-
|-
|2
|1||source directory
|source directory
|-
|-
|3
|2||zip filename
|zipfilename
|-
|-
|4
|3 || <code>-pattern</code> or <code>–list</code>
|<code>-pattern</code> or <code>-list</code>
|-
|-
|5
|4||the pattern or a comma-separated list
|the pattern or a comma-separated list
|}
|}


;Example 1:
'''Example 1''': Compresses all files in directory d:\temp\ with the extension *.txt to the file myfile.zip
:Compresses all files in directory <code>d:\temp\</code> with <code>*.txt</code>-extension to file <code>myfile.zip</code>
<pre>
:<code>SydroCmd -zip d:\temp\ myfile.zip -pattern *.txt</code>
SydroCmd –zip d:\temp\ myfile.zip –pattern *.txt
</pre>


;Example 2:
'''Example 2''': Compresses a list of files in directory d:\temp\ with the extension *.txt to the file myzipfile.zip
:Compresses a list of files in directory <code>d:\temp\</code> with <code>*.txt</code>-extension to file <code>myfile.zip</code>
:<code>SydroCmd -zip d:\temp\ myzipfile.zip -list d:\mylist\file1.txt "d:\many files\newfile.doc"</code>


<pre>
SydroCmd -zip  d:\temp\ myzipfile.zip -list d:\mylist\file1.txt "d:\many files\newfile.doc"
</pre>


==UnZip==
==UnZip==
UnZips files from a Zip File.
Unzips files from a zip file.
{| class=wikitable
! Argument !! Description
|-
|Key || <code>-unzip</code>
|-
|1||source directory
|-
|2||source zip filename
|-
|3 || <code>-pattern</code> or <code>-list</code>
|-
|4||the pattern or a comma-separated  list
|}


{| class="wikitable" style="width: 50%;"
'''Example 1''': Unzips all files in directory d:\temp\ and zipfile myfile.zip with the pattern *.txt to d:\
!style="width: 10%"|Argument
 
!style="width: 90%"|Description
<pre>
SydroCmd -unzip d:\ d:\temp\myfile.zip -pattern *.txt
</pre>
 
'''Example 2''': Unzips a selection of files from d:\temp\ and  myzipfile to d:\
 
<pre>
SydroCmd -unzip d:\ d:\temp\myzipfile.zip -list d:\mylist\file1.txt "d:\any directory\newfile.doc"
</pre>
 
'''Example 3''': Unzips all files in the zipfile from d:\temp\ and myzipfile to d:\
 
<pre>
SydroCmd -unzip d:\ d:\temp\myzipfile.zip –pattern *.*
</pre>
 
==TimeSeries - GET==
Retrieves a SydroTimeSeries object from the TalsimNGServer via REST interface.
 
{| class=wikitable border=1 cellspacing=0 cellpadding=0
!Argument!!Description
|-
|-
|1
|Key || timeseries
|<code>-unzip</code>
|-
|-
|2
|1 || <code>-get</code>
|source directory
|-
|-
|3
|2||Customer name, e.g. <code>Test</code> or <code>KS_Gerstungen</code>
|source zipfilename
|-
|-
|4
|3||User, e.g. <code>Felix</code>
|<code>-pattern</code> or <code>-list</code>
|-
|-
|5
|4||Id of the time series, e.g. <code>406420</code>
|the pattern or a comma-separated list
|-
|5||Startdate in <code>yyyy-MM-dd HH:mm</code> format or <code>0</code> for all entries from the beginning
|-
|6||Enddate in <code>yyyy-MM-dd HH:mm</code> format or <code>0</code> for all entries up to the end
|-
|7||Flag to specifiy which data are to  be retrieved, e.g. <code>0</code>, <code>1</code>, etc.
|-
|8||Protocol, usually <code>http</code>
|-
|9||IP address, e.g. <code>localhost</code> or <code>10.0.0.5</code>
|-
|10||Port. The default port is <code>8092</code>
|-
|11||Filename. The destination file of the time series, e.g. <code>d:\temp\timeseries.short.txt</code>. '''No blank (space) is allowed in the path and name.'''
|}
|}


;Example 1:  
'''Example 1''': The file timeseries.short.txt should be fetched from customer KS_Gerstungen. The time series  has the Id 406420, the whole time series is desired. Only entries with the flag 0 are wanted. The server is located at 10.0.0.30. The result will be written to d:\temp\timeseries.long.txt.
: Unzips all files in directory <code>d:\temp\</code> and zipfile <code>myfile.zip</code> with the pattern <code>*.txt</code> to <code>d:\</code>
 
:<code>SydroCmd -unzip d:\ d:\temp\myfile.zip -pattern *.txt</code>
<pre>
SydroCmd.exe -timeseries -get KS_Gerstungen,hubert,406420,0,0,1,http,10.0.0.30,8092,d:\temp\timeseries.long.txt
</pre>
 
'''Example  2''': The timeseries  with the Id 9998 is needed from customer TestApi.
 
<pre>
SydroCmd -timeseries -get TestApi,hubert,9998,0,0,-1,http,localhost,8092,d:\temp\timeseries.short.txt
</pre>
 
==TimeSeries - POST==
Uploads a SydroTimeSeries object to the TalsimNGServer via REST interface. All settings like Flag, SaveMetadata etc. are given in the SydroTimeSeries object itself.
 
{| class=wikitable border=1 cellspacing=0 cellpadding=0
!Argument!!Description
|-
|Key || timeseries
|-
|1 || <code>-post</code>
|-
|2||Customer, e.g. <code>Test</code> or <code>KS_Gerstungen</code>
|-
|3||User, e.g. <code>Felix</code>
|-
|4||Id of the time series, e.g. <code>406420</code>
|-
|8||Protocol, usually <code>http</code>
|-
|9||IP address, e.g. <code>localhost</code> or  <code>10.0.0.5</code>
|-
|10||Port. The default port is <code>8092</code>
|-
|11||Source filename. The path to the time series file, e.g. <code>d:\temp\timeseries.short.txt</code>. '''No blank (space) is  allowed in the path and name.'''
|}


;Example 2:
'''Example 1''': The file timeseries.short.txt should be uploaded to customer TestAPI. The time series has the  Id 9999 and the file is located at d:\temp\timeseries.short.txt.
:Unzips a selection of files from <code>d:\temp\</code> and <code>myzipfile</code> to <code>d:\</code>
:<code>SydroCmd -unzip d:\ d:\temp\myzipfile.zip -list d:\mylist\file1.txt "d:\any directory\newfile.doc"</code>


;Expamle 3:
<pre>
:Unzips all files in the zipfile from <code>d:\temp\</code> and <code>myzipfile</code> to <code>d:\</code>
SydroCmd.exe -timeseries -post TestApi,hubert,9999,http,localhost,8092,d:\temp\timeseries.short.txt
:<code>SydroCmd -unzip d:\ d:\temp\myzipfile.zip -pattern *.*</code>
</pre>

Version vom 29. Juni 2020, 12:19 Uhr

Extract

Extracts strings from each line within an ASCII file.

Argument Description
Key -extract
1 sourcefile
2 -string: search for a string

-pos: select a position
-split: split a string

3 either string or position as a number
4 -endstring, –endlen or -array
5 either a string or the word blank or a position as an integer, depending on the previous argument. With -split a comma-separated list of indices is required indicating which items should be saved.
6 targetfile

Example 1: extracts a string from each line within d:\temp\abc.txt which follows directly after "val=" and ends at the next blank.

SydroCmd -extract d:\temp\abc.txt -string val= -endstring blank d:\temp\extract.txt

Example 2: extracts a string from each line within d:\temp\abc.txt starting from position 15 with a length of 25 characters.

SydroCmd -extract d:\temp\abc.txt -pos 15 -endlen 25 d:\temp\extract.txt

Download

Downloads a file with a valid URL to the local machine.

Argument Description
Key -download or -downloadwget (the latter causes wget to be used for downloading)
1 URL (possibly with placeholders like {0})
2 Arguments separated by a comma filling the placeholders in the URL
3 targetfile

Example: Downloads a file from the NOAA data archive. Variables are the year, month, day.

SydroCmd -download http://nomads.ncdc.noaa.gov/modeldata/cfsv2_forecast_mm_9mon/{0}/{0}{1}/{0}{1}{2}/{0}{1}{2}00/flxf.01.{0}{1}{2}00.{3}{4}.avrg.grib.grb2  2016,12,02,2016,12 D:\temp\tmp.grb2

Replace

Replaces all strings with a new string within a file. Is able to handle current date information.

Argument Description
Key -replace
1 sourcefile
2 search string or DATE
3 replace string or a date in the format yyyyMMddHHmm or Now
4 targetfile (if not given, then sourcefile will be overwritten)

Date replacement

If the search string is the keyword DATE, dynamic date replacement takes place:

  • The replace string must then be a date in the format yyyyMMddHHmm or Now.
  • In the sourcefile, the placeholder to be replaced must be given as follows: {DATE|ValidFormatstring|ValidNumber,DateInterval}, where
    • ValidFormatstring: a date format string consisting of e.g. yyyy, MM, dd, HH, mm (see here for more options)
    • ValidNumber: 0, +2, -5 or any other integer (adds/subtracts the number of years, months, days, hours, minutes as given with the number)
    • DateIntervall= y, M, d, h, m (is used to add the ValidNumber to the date)
Example: {DATE|dd|+1,d} with a replace date of 30/12/2017 results in 31 (given date + 1 day, expressed as date (dd)).

Examples

Example 1: simple replacement of "hello" with "goodbye". The sourcefile will be overwritten.

SydroCmd –replace d:\temp\abc.txt hello goodbye

Example 2: with date information

In this example the first argument is the keyword DATE indicating that date information is used. If this string is found it will be replaced by the date given in the next argument (here 5/12/2016 00:00). In the file abc.txt the variable to be replaced must be given as follows: {DATE|yyyy|+1,y}. This means the result will be 2017, one year added to 2016.

SydroCmd –replace d:\temp\abc.txt DATE 201612050000 d:\temp\abcnew.txt

Example 2: with date information using Now

In this example the first argument is the keyword DATE indicating that date information is used. If this string is found it will be replaced by the date given in the next argument (here the keyword Now). In the file abc.txt the variable to be replaced must be given as follows: {DATE|yyyyMMdd|+1,M}. This means the result will be the current date plus one month.

SydroCmd –replace d:\temp\abc.txt DATE Now d:\temp\abcnew.txt

Zip

Compress files to a zip file.

Argument Description
Key -zip
1 source directory
2 zip filename
3 -pattern or –list
4 the pattern or a comma-separated list

Example 1: Compresses all files in directory d:\temp\ with the extension *.txt to the file myfile.zip

SydroCmd  –zip d:\temp\ myfile.zip –pattern *.txt

Example 2: Compresses a list of files in directory d:\temp\ with the extension *.txt to the file myzipfile.zip

SydroCmd -zip  d:\temp\ myzipfile.zip -list d:\mylist\file1.txt "d:\many files\newfile.doc"

UnZip

Unzips files from a zip file.

Argument Description
Key -unzip
1 source directory
2 source zip filename
3 -pattern or -list
4 the pattern or a comma-separated list

Example 1: Unzips all files in directory d:\temp\ and zipfile myfile.zip with the pattern *.txt to d:\

SydroCmd -unzip d:\ d:\temp\myfile.zip -pattern *.txt

Example 2: Unzips a selection of files from d:\temp\ and myzipfile to d:\

SydroCmd -unzip d:\ d:\temp\myzipfile.zip -list d:\mylist\file1.txt "d:\any directory\newfile.doc"

Example 3: Unzips all files in the zipfile from d:\temp\ and myzipfile to d:\

SydroCmd -unzip d:\ d:\temp\myzipfile.zip –pattern *.*

TimeSeries - GET

Retrieves a SydroTimeSeries object from the TalsimNGServer via REST interface.

Argument Description
Key timeseries
1 -get
2 Customer name, e.g. Test or KS_Gerstungen
3 User, e.g. Felix
4 Id of the time series, e.g. 406420
5 Startdate in yyyy-MM-dd HH:mm format or 0 for all entries from the beginning
6 Enddate in yyyy-MM-dd HH:mm format or 0 for all entries up to the end
7 Flag to specifiy which data are to be retrieved, e.g. 0, 1, etc.
8 Protocol, usually http
9 IP address, e.g. localhost or 10.0.0.5
10 Port. The default port is 8092
11 Filename. The destination file of the time series, e.g. d:\temp\timeseries.short.txt. No blank (space) is allowed in the path and name.

Example 1: The file timeseries.short.txt should be fetched from customer KS_Gerstungen. The time series has the Id 406420, the whole time series is desired. Only entries with the flag 0 are wanted. The server is located at 10.0.0.30. The result will be written to d:\temp\timeseries.long.txt.

SydroCmd.exe -timeseries -get KS_Gerstungen,hubert,406420,0,0,1,http,10.0.0.30,8092,d:\temp\timeseries.long.txt

Example 2: The timeseries with the Id 9998 is needed from customer TestApi.

SydroCmd -timeseries -get TestApi,hubert,9998,0,0,-1,http,localhost,8092,d:\temp\timeseries.short.txt

TimeSeries - POST

Uploads a SydroTimeSeries object to the TalsimNGServer via REST interface. All settings like Flag, SaveMetadata etc. are given in the SydroTimeSeries object itself.

Argument Description
Key timeseries
1 -post
2 Customer, e.g. Test or KS_Gerstungen
3 User, e.g. Felix
4 Id of the time series, e.g. 406420
8 Protocol, usually http
9 IP address, e.g. localhost or 10.0.0.5
10 Port. The default port is 8092
11 Source filename. The path to the time series file, e.g. d:\temp\timeseries.short.txt. No blank (space) is allowed in the path and name.

Example 1: The file timeseries.short.txt should be uploaded to customer TestAPI. The time series has the Id 9999 and the file is located at d:\temp\timeseries.short.txt.

SydroCmd.exe -timeseries -post TestApi,hubert,9999,http,localhost,8092,d:\temp\timeseries.short.txt