Retourner aux forums || Retourner au forum Programmation.c#
Programmation.c# : Exécuter un commande Shell
Posté par Étienne Bersac (Jabber id, page perso, ) le 31 janvier 2005Je suis débutant en C#, et je ne sais pas comment exécuter une commande autrement quand dans un Vte. Comment faire. Je ne sais pas non plus le faire en C.
Je cherche une fonction du genre Exec("whoami"). (on s'en fout de la commande).
Merci
E Ultreïa !
SYSTEM(3)
man 3 system:
NAME
system - execute a shell command
SYNOPSIS
#include <stdlib.h>
int system(const char *command);
DESCRIPTION
system() executes a command specified in command by calling /bin/sh -c
command, and returns after the command has been completed. During exe-
cution of the command, SIGCHLD will be blocked, and SIGINT and SIGQUIT
will be ignored.
class Process
Process p = new Process();
p.StartInfo = new ProcessStartInfo(); //peut être pas nécessaire :-)
p.StartInfo.FileName = "monexecutable";
p.Start();
Tu peux toucher à pleins de trucs dans la variable Process si tu veux.
Par ici tu trouveras comment récupérer la sortie par exemple :
http://perso.3ie.org/yannick.lejeune/archives/2004_04_01_blog-progr(...)
Pour plus d'infos sur la classe :
http://www.go-mono.com/docs/index.aspx?tlink=9@ecma%3a1211%23Proces(...)
MERCI
Merci beaucoup à vous deux pour le C et le C#. :)
E Ultreïa !
Revenir en haut de page || Retourner aux forums || Retourner au forum Programmation.c#



Cette discussion est archivée, il n'est plus possible de laisser des commentaires.
Note : les commentaires appartiennent à ceux qui les ont postés. Nous n'en sommes pas responsables.