Arbeiten mit dem SydroCmd tool: Unterschied zwischen den Versionen
Keine Bearbeitungszusammenfassung |
|||
Zeile 6: | Zeile 6: | ||
<code>SydroCmd -command Arg1 Arg2 Arg3 Arg4</code> | <code>SydroCmd -command Arg1 Arg2 Arg3 Arg4</code> | ||
==SydroCmd-Verzeichnisstruktur und Dateien== | |||
Da das SydroCmd-tool oft vom TaskServer aus gestartet wird empfiehlt es sich sämtliche zum SydroCmd-tool gehörenden Dateien in dasselbe [[TaskSrv-Verzeichnis:_Exe|Verzeichnis]] wie die ausführbare Programmdatei des TaskServers zu legen. | |||
===SydroCmd.exe=== | |||
==SydroCmd Befehle== | ==SydroCmd Befehle== |
Version vom 18. Juli 2019, 11:06 Uhr
Das Kommandozeilenwerkzeug von Sydro SydroCmd.exe
kann als alleinstehendes Werkzeug benutzt werden oder über den TaskServer konfiguriert und aufgerufen werden. Es wird im Pre- und Postprocessing sowie im Operationellen Einsatz von Talsim-NG genutzt.
Anwendung des SydroCmd tools
Die Anwendung des SydroCmd tools ist sehr simpel. Es wird über die Kommandozeile aufgerufen zusammen mit dem Schlüssel für den auszuführenden Befehl und den dazugehörenden Argumenten, jeweils getrennt durch ein Leerzeichen:
SydroCmd -command Arg1 Arg2 Arg3 Arg4
SydroCmd-Verzeichnisstruktur und Dateien
Da das SydroCmd-tool oft vom TaskServer aus gestartet wird empfiehlt es sich sämtliche zum SydroCmd-tool gehörenden Dateien in dasselbe Verzeichnis wie die ausführbare Programmdatei des TaskServers zu legen.
SydroCmd.exe
SydroCmd Befehle
Extract
Extracts strings from each line within an ASCII file.
Argument | Description |
---|---|
Key | -extract
|
1 | sourcefile |
2 | -string or -pos or -split ( -string =search for a string, -pos =select a position, -split =delimits the string)
|
3 | either string or position as a number |
4 | -endstring or -endlen or -array
|
5 | either a string or the work blank or a position as integer, depending on the previous argument. With -split a comma-separated list of indices is required indicating which items should be saved
|
6 | targetfile |
- Example1
- extracts a string from each line within
d:\temp\abc.txt
which follows directly afterval=
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 memory.
Argument | Description |
---|---|
Key | -download
|
1 | URL (possibly with spaceholders like {0}
|
2 | Arguments separated by a comma filling the spaceholders 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 | string to be searched for (see options) |
3 | Replacement string, string to be inserted (see options) |
4 | targetfile (if not given, sourcefile will be overwritten) |
Options
- 2. Argument
- String to be searched for that will be replaced
- Format=
[KEYWORD|Valid Formatstring|Valid Number,DateInterval}
KEYWORD = CURRENTDATE
Valid Formatstring
= possible isyyy
,MM
,dd
,mm
Valid Number
=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 thevalid number
to the date)
- Example:
{CURRENTDATE|dd|+1,d}
with a date 30/12/2017 results in 31
- 3. Argument
- ordinary string or in combination with
CURRENTDATE
a date in the formatyyyyMMDDhhmm
or the keywordNow
Examples
- Example1
- simple with “hallo” replaced by “goodbye”. The sourcefile will be overwritten.
SydroCmd -replace d:\temp\abc.txt hallo goodbye
- Example2
- with date information
SydroCmd -replace d:\temp\abc.txt CURRENTDATE 201612050000 d:\temp\abcnew.txt
- In this example the first argument is
CURRENDATE
indicating that date information is used. If this string is found it will be replaced by the date given in the next argument (here5/12/2016 00:00
). In theabc.txt
the variable to be replaced must be given as follows:{CURRENTDATE|yyyy|+1,y}
. This means the result will be ‘2017’, one year added to 2016.
Zip
Zips files into a Zip File Format.
Argument | Description |
---|---|
Key | -zip
|
1 | source directory |
2 | zipfilename |
3 | -pattern or -list
|
4 | the pattern or a comma-separated list |
- Example 1
- Compresses all files in directory
d:\temp\
with*.txt
-extension to filemyfile.zip
SydroCmd -zip d:\temp\ myfile.zip -pattern *.txt
- Example 2
- Compresses a list of files in directory
d:\temp\
with*.txt
-extension to filemyfile.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 zipfilename |
3 | -pattern or -list
|
4 | the pattern or a comma-separated list |
- Example 1
- Unzips all files in directory
d:\temp\
and zipfilemyfile.zip
with the pattern*.txt
tod:\
SydroCmd -unzip d:\ d:\temp\myfile.zip -pattern *.txt
- Example 2
- Unzips a selection of files from
d:\temp\
andmyzipfile
tod:\
SydroCmd -unzip d:\ d:\temp\myzipfile.zip -list d:\mylist\file1.txt "d:\any directory\newfile.doc"
- Expamle 3
- Unzips all files in the zipfile from
d:\temp\
andmyzipfile
tod:\
SydroCmd -unzip d:\ d:\temp\myzipfile.zip -pattern *.*