ComposantsComponents › SystèmeSystem
Exécute une commande du système (un programme, un script, une commande de cmd) et attend qu'elle se termine. Ce qu'elle écrit va dans la console du job, dans une variable globale ou dans un flux ; son code de retour est rangé dans une variable globale.
Executes a system command (a program, a script, a cmd command) and waits for it to end. What it writes goes to the job console, to a global variable or to a flow; its exit code is stored in a global variable.
EntréeInput
Aucune : il peut commencer un sous-job. Sinon un lien Iterate : une commande par itération. None: it can start a subjob. Otherwise one Iterate link: one command per iteration.
SortieOutput
Un lien Main, seulement quand une des sorties vaut normal : une ligne du flux par ligne écrite. One Main link, only when one of the outputs is normal: one flow row per written line.
Déclencheurs en sortieOutput triggers
On Subjob Ok On Subjob Error Run if
Pas de On Component Ok ni On Component Error en sortie : le composant ne les propose pas. No outgoing On Component Ok or On Component Error: the component does not offer them.
Le job attend la fin de la commande avant de continuer : un script qui prépare un fichier, une copie, une conversion. The job waits for the end of the command before going on: a script that prepares a file, a copy, a conversion.
Avec la sortie à normal, chaque ligne écrite par la commande devient une ligne du flux, dans la colonne outputline, à traiter comme les données d'un fichier.
With the output set to normal, each line written by the command becomes a flow row, in the outputline column, to process like the data of a file.
cmd (echo, dir, copy…) se lance par cmd /c.
Write the command in Command, in quotes: it is a Java expression. On Windows, an internal command of cmd (echo, dir, copy…) is run through cmd /c.
EXIT_VALUE) dans un Run if ou un tJava.
Choose where Standard Output and Error Output go, then test the exit code (EXIT_VALUE) in a Run if or a tJava.
Les libellés sont ceux de l'onglet Composant ; le nom technique, en gris, est celui du paramètre dans le fichier du job. Le composant n'a pas de paramètres avancés propres. Labels are those of the Component tab; the technical name, in grey, is the parameter name in the job file. The component has no advanced settings of its own.
| ParamètreSetting | DéfautDefault | VisibleShown | Description |
|---|---|---|---|
| Utiliser le répertoire principalUse Home DirectoryROOTDIR | NonNo | ToujoursAlways | Lance la commande dans le dossier de Répertoire principal. Décochée, la commande part du dossier courant du job. Runs the command in the Home Directory folder. Unchecked, the command starts from the current folder of the job. |
| Répertoire principalHome DirectoryDIRECTORY | dossier par défaut des fichiers du Studiodefault file folder of the Studio | Répertoire principal cochéHome Directory checked |
Dossier de travail de la commande, expression Java entre guillemets ("C:/Windows").
Working folder of the command, Java expression in quotes ("C:/Windows").
|
| Utiliser une commande seuleUse Single CommandUSE_SINGLE_COMMAND | OuiYes | ToujoursAlways | La commande est un seul texte. Choix exclusif avec Utiliser commande Array. The command is a single text. Exclusive choice with Use Array Command. |
| CommandeCommandCOMMAND | "cmd /c echo HELLO" |
Commande seuleSingle command | Expression Java de type texte. Elle est coupée à chaque espace pour donner le programme et ses arguments ; les guillemets à l'intérieur ne regroupent rien (voir Pièges). Java expression of type text. It is cut at each space to give the program and its arguments; quotes inside do not group anything (see Pitfalls). |
| Utiliser commande ArrayUse Array CommandUSE_ARRAY_COMMAND | NonNo | ToujoursAlways | La commande est un tableau : le programme, puis un argument par ligne. The command is a table: the program, then one argument per row. |
| CommandeCommandARRAY_COMMAND | videempty | Commande ArrayArray command | Une expression Java par ligne (colonne valeur). Chaque ligne reste un seul argument, espaces compris. One Java expression per row (value column). Each row stays a single argument, spaces included. |
| Sortie standardStandard OutputOUTPUT | vers la consoleto console | ToujoursAlways |
vers la console : chaque ligne est écrite dans la console du job. vers la variable globale : les lignes sont rangées dans OUTPUT, séparées par \n. vers la console et vers la variable globale : les deux. normal : chaque ligne devient une ligne du flux de sortie.
to console: each line is written to the job console. to global variable: the lines are stored in OUTPUT, separated by \n. to both console and global variable: both. normal: each line becomes a row of the output flow.
|
| Sortie des erreursError OutputERROROUTPUT | vers la consoleto console | ToujoursAlways |
Les mêmes choix pour la sortie d'erreur de la commande : la console (sortie d'erreur du job), la variable ERROROUTPUT, les deux, ou le flux.
The same choices for the error output of the command: the console (error output of the job), the ERROROUTPUT variable, both, or the flow.
|
| SchémaSchemaSCHEMA | outputline |
Une sortie à normalOne output normal |
La colonne outputline (String) reçoit chaque ligne. Avec les deux sorties à normal, leurs lignes arrivent dans le même flux.
The outputline column (String) receives each line. With both outputs set to normal, their lines come in the same flow.
|
| Variables d'environnementEnvironment variablesPARAMS | videempty | ToujoursAlways | Colonnes (nom) et valeur, des expressions Java. La commande reçoit l'environnement du job, plus ces variables ; une variable qui existe déjà prend la nouvelle valeur. name and value columns, Java expressions. The command gets the job environment, plus these variables; a variable that already exists takes the new value. |
Toutes trois disponibles après le composant : All three available after the component:
((Integer) globalMap.get("tSystem_1_EXIT_VALUE"))
((String) globalMap.get("tSystem_1_OUTPUT"))
((String) globalMap.get("tSystem_1_ERROROUTPUT"))
OUTPUT et ERROROUTPUT sont vidées au début de chaque exécution du composant : dans une boucle, elles ne gardent que la sortie de la commande en cours.
OUTPUT and ERROROUTPUT are cleared at the start of each run of the component: in a loop, they only keep the output of the current command.
Sous Windows. Sorties copiées depuis une exécution du job ; dans les erreurs, le nom du job est remplacé par MyJob et les traces d'exception sont abrégées.
On Windows. Outputs copied from a run of the job; in the errors, the job name is replaced with MyJob and the exception traces are shortened.
Commande : "cmd /c echo HELLO". Le tJava affiche le code de retour.
Command: "cmd /c echo HELLO". The tJava prints the exit code.
System.out.println("Exit value: " + globalMap.get("tSystem_1_EXIT_VALUE"));
HELLO Exit value: 0
Commande : "cmd /c echo Ada& echo Grace" (deux lignes), sortie standard vers la variable globale. Un tJava relié par On Subjob Ok :
Command: "cmd /c echo Ada& echo Grace" (two lines), standard output to global variable. A tJava connected with On Subjob Ok:
String output = (String) globalMap.get("tSystem_1_OUTPUT");
String[] lines = output.split("\n");
System.out.println(lines.length + " lines, the last one: " + lines[lines.length - 1]);
2 lines, the last one: Grace
La commande n'écrit plus rien dans la console. Avec vers la console et vers la variable globale, les deux lignes s'affichent aussi : The command no longer writes anything to the console. With to both console and global variable, the two lines are printed too:
Ada Grace Global variable: Ada + Grace
(le tJava remplace ici \n par + )
(the tJava here replaces \n with + )
Même commande, sortie standard normal. Le tLogRow reçoit une ligne par ligne écrite, dans outputline.
Same command, standard output normal. The tLogRow receives one row per written line, in outputline.
Ada Grace
Commande : "cmd /c exit 3". Condition du Run if vers tJava_2 (qui écrit The command failed), et un tJava_1 relié par On Subjob Ok qui affiche le code :
Command: "cmd /c exit 3". Condition of the Run if to tJava_2 (which writes The command failed), and a tJava_1 connected with On Subjob Ok that prints the code:
((Integer) globalMap.get("tSystem_1_EXIT_VALUE")) != 0
The command failed Exit value: 3
Le composant ne signale pas d'erreur : On Subjob Ok est suivi et le job se termine avec le code 0. Seul le test de EXIT_VALUE voit l'échec.
The component reports no error: On Subjob Ok is followed and the job ends with code 0. Only the test of EXIT_VALUE sees the failure.
Commande : "cmd /c (echo Something went wrong)1>&2", qui écrit sur la sortie d'erreur ; sortie des erreurs vers la variable globale. Un tJava relié par On Subjob Ok :
Command: "cmd /c (echo Something went wrong)1>&2", which writes to the error output; error output to global variable. A tJava connected with On Subjob Ok:
System.out.println("Error output: " + globalMap.get("tSystem_1_ERROROUTPUT"));
Error output: Something went wrong
Commande : "cmd /c echo %GREETING%". Variables d'environnement : "GREETING" / "Hello Ada".
Command: "cmd /c echo %GREETING%". Environment variables: "GREETING" / "Hello Ada".
Hello Ada
Même sortie en commande Array, avec trois lignes : "cmd", "/c", "echo %GREETING%".
Same output as an Array command, with three rows: "cmd", "/c", "echo %GREETING%".
Commande : "cmd /c cd" (affiche le dossier courant). Utiliser le répertoire principal coché, Répertoire principal : "C:/Windows".
Command: "cmd /c cd" (prints the current folder). Use Home Directory checked, Home Directory: "C:/Windows".
C:\Windows
tLoop de 1 à 2. La commande est construite avec le numéro de l'itération, sortie standard vers la variable globale ; condition du Run if : true.
tLoop from 1 to 2. The command is built with the iteration number, standard output to global variable; Run if condition: true.
// tSystem_1 › Commande / Command
"cmd /c echo Iteration " + globalMap.get("tLoop_1_CURRENT_VALUE")
// tJava_1
System.out.println("tSystem_1_OUTPUT = [" + globalMap.get("tSystem_1_OUTPUT") + "]");
tSystem_1_OUTPUT = [Iteration 1] tSystem_1_OUTPUT = [Iteration 2]
À la deuxième itération, la variable ne contient que la sortie de la deuxième commande. At the second iteration, the variable only holds the output of the second command.
cmd sans cmd /cInternal cmd command without cmd /c
Commande : "ver". Les commandes internes de cmd ne sont pas des programmes : Windows ne trouve rien à lancer et le job s'arrête (code 1). La fin du message vient de Windows, dans sa langue.
Command: "ver". The internal commands of cmd are not programs: Windows finds nothing to start and the job stops (code 1). The end of the message comes from Windows, in its language.
Exception in component tSystem_1 (MyJob) java.io.IOException: Cannot run program "ver": CreateProcess error=2, Le fichier spécifié est introuvable at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1170) …
Écrivez "cmd /c ver". Une commande que l'on trouve aussi sous forme de programme dans le PATH du poste (un echo.exe installé avec Git, par exemple) fonctionne sans cmd /c sur ce poste seulement.
Write "cmd /c ver". A command also found as a program in the PATH of the machine (an echo.exe installed with Git, for example) works without cmd /c on that machine only.
Commande seule : "cmd /c echo \"two spaces\"", avec deux espaces entre les mots.
Single command: "cmd /c echo \"two spaces\"", with two spaces between the words.
"two spaces"
Le texte est coupé à chaque suite d'espaces, sans tenir compte des guillemets : "two et spaces" deviennent deux arguments, et un seul espace les sépare à l'arrivée. Pour un argument qui contient des espaces (un chemin, un texte), prenez Utiliser commande Array : une ligne par argument.
The text is cut at each run of spaces, ignoring quotes: "two and spaces" become two arguments, and only one space separates them in the end. For an argument that contains spaces (a path, a text), take Use Array Command: one row per argument.
Le composant attend la fin de la commande et de ses sorties. Une commande qui ne se termine pas (une fenêtre restée ouverte, une question posée à l'utilisateur) bloque le job. The component waits for the end of the command and of its outputs. A command that does not end (a window left open, a question asked to the user) blocks the job.
La commande par défaut, cmd /c, n'existe que sous Windows. Un job qui doit tourner aussi sous Linux peut construire sa commande selon System.getProperty("os.name"), ou lancer un script fourni pour chaque système.
The default command, cmd /c, only exists on Windows. A job that must also run on Linux can build its command from System.getProperty("os.name"), or start a script provided for each system.
Les autres composants de la famille Système : The other components of the System family:
tRunJob · lance un autre job du projetruns another job of the projecttSSH · exécute des commandes via SSHexecutes commands through SSHtSetEnv · pose des propriétés système Java (pas l'environnement de la commande)sets Java system properties (not the command environment)tJava · code Java exécuté une foisJava code run once