SydroCmd Befehle: Unterschied zwischen den Versionen

Aus TALSIM Docs
Keine Bearbeitungszusammenfassung
(Diese Seite wurde zum Übersetzen freigegeben)
Zeile 2: Zeile 2:
<translate>
<translate>


<!--T: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== <!--T:2-->


<!--T:3-->
Extracts strings from each line within an ASCII file.
Extracts strings from each line within an ASCII file.


<!--T:4-->
{| class=wikitable
{| class=wikitable
!Argument !! Description
!Argument !! Description
Zeile 30: Zeile 33:
|}  
|}  


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


<!--T:6-->
<pre>
<pre>
SydroCmd -extract d:\temp\abc.txt -string val= -endstring blank d:\temp\extract.txt
SydroCmd -extract d:\temp\abc.txt -string val= -endstring blank d:\temp\extract.txt
</pre>
</pre>


<!--T:7-->
'''Example 2''': extracts a string  from each line within d:\temp\abc.txt starting from position 15 with a length  of 25 characters.  
'''Example 2''': extracts a string  from each line within d:\temp\abc.txt starting from position 15 with a length  of 25 characters.  


<!--T:8-->
<pre>
<pre>
SydroCmd -extract d:\temp\abc.txt -pos 15 -endlen 25 d:\temp\extract.txt
SydroCmd -extract d:\temp\abc.txt -pos 15 -endlen 25 d:\temp\extract.txt
Zeile 43: Zeile 50:




==Download==
==Download== <!--T:9-->


<!--T:10-->
Downloads a file with a valid URL to the local machine.
Downloads a file with a valid URL to the local machine.


<!--T:11-->
{| class=wikitable
{| class=wikitable
! Argument !! Description
! Argument !! Description
Zeile 59: Zeile 68:
|}
|}


<!--T:12-->
'''Example:''' Downloads a  file from the NOAA data archive. Variables are the year, month, day.
'''Example:''' Downloads a  file from the NOAA data archive. Variables are the year, month, day.


<!--T:13-->
<pre>
<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
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
Zeile 66: Zeile 77:




==Replace==
==Replace== <!--T:14-->


<!--T:15-->
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.


<!--T:16-->
{| class=wikitable
{| class=wikitable
! Argument !! Description
! Argument !! Description
Zeile 85: Zeile 98:




===Date replacement===
===Date replacement=== <!--T:17-->


<!--T:18-->
If the search string is the keyword <code>DATE</code>, dynamic date replacement takes place:
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>.
* The replace string must then be a date in the format <code>yyyyMMddHHmm</code> or <code>Now</code>.
Zeile 96: Zeile 110:




===Examples===
===Examples=== <!--T:19-->


<!--T:20-->
'''Example 1''': simple replacement of "hello" with "goodbye". The sourcefile will be overwritten.
'''Example 1''': simple replacement of "hello" with "goodbye". The sourcefile will be overwritten.
<pre>
<pre>
Zeile 103: Zeile 118:
</pre>
</pre>


<!--T:21-->
'''Example 2''': with date information
'''Example 2''': with date information


<!--T:22-->
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.
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.


<!--T:23-->
<pre>
<pre>
SydroCmd –replace d:\temp\abc.txt DATE 201612050000 d:\temp\abcnew.txt
SydroCmd –replace d:\temp\abc.txt DATE 201612050000 d:\temp\abcnew.txt
</pre>
</pre>


<!--T:24-->
'''Example 2''': with date information using <code>Now</code>
'''Example 2''': with date information using <code>Now</code>


<!--T:25-->
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.
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.


<!--T:26-->
<pre>
<pre>
SydroCmd –replace d:\temp\abc.txt DATE Now d:\temp\abcnew.txt
SydroCmd –replace d:\temp\abc.txt DATE Now d:\temp\abcnew.txt
Zeile 120: Zeile 141:




==Zip==
==Zip== <!--T:27-->


<!--T:28-->
Compress files to a zip file.
Compress files to a zip file.


<!--T:29-->
{| class=wikitable  
{| class=wikitable  
! Argument !! Description
! Argument !! Description
Zeile 138: Zeile 161:
|}
|}


<!--T:30-->
'''Example 1''': Compresses all files in directory d:\temp\ with the extension *.txt to the file myfile.zip
'''Example 1''': Compresses all files in directory d:\temp\ with the extension *.txt to the file myfile.zip
<pre>
<pre>
Zeile 143: Zeile 167:
</pre>
</pre>


<!--T:31-->
'''Example 2''': Compresses a list of files in directory d:\temp\ with the extension *.txt to the file myzipfile.zip
'''Example 2''': Compresses a list of files in directory d:\temp\ with the extension *.txt to the file myzipfile.zip


<!--T:32-->
<pre>
<pre>
SydroCmd -zip  d:\temp\ myzipfile.zip -list d:\mylist\file1.txt "d:\many files\newfile.doc"
SydroCmd -zip  d:\temp\ myzipfile.zip -list d:\mylist\file1.txt "d:\many files\newfile.doc"
Zeile 150: Zeile 176:




==UnZip==
==UnZip== <!--T:33-->


<!--T:34-->
Unzips files from a zip file.
Unzips files from a zip file.
{| class=wikitable
{| class=wikitable
Zeile 167: Zeile 194:
|}  
|}  


<!--T:35-->
'''Example 1''': Unzips all files in directory d:\temp\ and zipfile myfile.zip with the pattern *.txt to d:\
'''Example 1''': Unzips all files in directory d:\temp\ and zipfile myfile.zip with the pattern *.txt to d:\


<!--T:36-->
<pre>
<pre>
SydroCmd -unzip d:\ d:\temp\myfile.zip -pattern *.txt
SydroCmd -unzip d:\ d:\temp\myfile.zip -pattern *.txt
</pre>
</pre>


<!--T:37-->
'''Example 2''': Unzips a selection of files from d:\temp\ and  myzipfile to d:\
'''Example 2''': Unzips a selection of files from d:\temp\ and  myzipfile to d:\


<!--T:38-->
<pre>
<pre>
SydroCmd -unzip d:\ d:\temp\myzipfile.zip -list d:\mylist\file1.txt "d:\any directory\newfile.doc"
SydroCmd -unzip d:\ d:\temp\myzipfile.zip -list d:\mylist\file1.txt "d:\any directory\newfile.doc"
</pre>
</pre>


<!--T:39-->
'''Example 3''': Unzips all files in the zipfile from d:\temp\ and myzipfile to d:\
'''Example 3''': Unzips all files in the zipfile from d:\temp\ and myzipfile to d:\


<!--T:40-->
<pre>
<pre>
SydroCmd -unzip d:\ d:\temp\myzipfile.zip –pattern *.*
SydroCmd -unzip d:\ d:\temp\myzipfile.zip –pattern *.*
Zeile 186: Zeile 219:




==TimeSeries - GET==
==TimeSeries - GET== <!--T:41-->


<!--T:42-->
Retrieves a SydroTimeSeries object from the TalsimNGServer via REST interface.  
Retrieves a SydroTimeSeries object from the TalsimNGServer via REST interface.  


<!--T:43-->
{| class=wikitable border=1 cellspacing=0 cellpadding=0  
{| class=wikitable border=1 cellspacing=0 cellpadding=0  
!Argument!!Description
!Argument!!Description
Zeile 218: Zeile 253:
|}
|}


<!--T:44-->
'''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.
'''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.


<!--T:45-->
<pre>
<pre>
SydroCmd.exe -timeseries -get KS_Gerstungen,hubert,406420,0,0,1,http,10.0.0.30,8092,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
</pre>
</pre>


<!--T:46-->
'''Example  2''': The timeseries  with the Id 9998 is needed from customer TestApi.
'''Example  2''': The timeseries  with the Id 9998 is needed from customer TestApi.


<!--T:47-->
<pre>
<pre>
SydroCmd -timeseries -get TestApi,hubert,9998,0,0,-1,http,localhost,8092,d:\temp\timeseries.short.txt
SydroCmd -timeseries -get TestApi,hubert,9998,0,0,-1,http,localhost,8092,d:\temp\timeseries.short.txt
Zeile 231: Zeile 270:




==TimeSeries - POST==
==TimeSeries - POST== <!--T:48-->


<!--T:49-->
Uploads a SydroTimeSeries object to the TalsimNGServer via REST interface. All settings like Flag, SaveMetadata etc. are given in the SydroTimeSeries object itself.
Uploads a SydroTimeSeries object to the TalsimNGServer via REST interface. All settings like Flag, SaveMetadata etc. are given in the SydroTimeSeries object itself.


<!--T:50-->
{| class=wikitable border=1 cellspacing=0 cellpadding=0  
{| class=wikitable border=1 cellspacing=0 cellpadding=0  
!Argument!!Description
!Argument!!Description
Zeile 257: Zeile 298:
|}  
|}  


<!--T:51-->
'''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.
'''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.


<!--T:52-->
<pre>
<pre>
SydroCmd.exe -timeseries -post TestApi,hubert,9999,http,localhost,8092,d:\temp\timeseries.short.txt
SydroCmd.exe -timeseries -post TestApi,hubert,9999,http,localhost,8092,d:\temp\timeseries.short.txt
</pre>
</pre>
</translate>
</translate>

Version vom 23. September 2020, 14:40 Uhr

Sprachen:


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