Article View: es.comp.os.linux.programacion
Article #14329re: hacer programa que coja parametros
From: manuel
Date: Thu, 16 Nov 2000 00:00
Date: Thu, 16 Nov 2000 00:00
41 lines
1596 bytes
1596 bytes
Hola!
Una idea podr�a ser:
int main (int argc, char *argv[])
{
char buffer[DE_TAMANO_SUFICIENTE];
/* argc es el numero de parametros que se le pasan al programa
incluyendo el nombre de este
por ejemplo, para 'wgetmio url', argc seria 2.
*/
if (argc != 2){
printf ("Uso: %s <url>\n", argv[0]); /* argv[0] es el nombre del
programa */
exit (-1);
}
strcpy (buffer, "wget -r -k -....");
strcat (buffer, " "); /* Un espacio para que todo vaya bien...*/
strcat (buffer, argv[1]); /* argv[1] es el primer parametro que le das
a tu programa */
if (system (buffer)){
printf ("Error al ejecutar el comando\n");
exit (-1);
}
printf ("Comando ejecutado correctamente\n");
exit (0);
}
Un saludo.
--
#
# Powered by: Debian 2.2 Potato (kernel 2.2.17)
#
Technical Details
Message-ID:
<%t_Q5.1109$B65.23532@m2newsread.uni2.es>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: SPANISH,ASCII X-Google-Thread: f86c8,fbf38259943327eb,start X-Google-Attributes: gidf86c8,public From: manuel <manoloci@wanadoo.es> Subject: re: hacer programa que coja parametros Date: 2000/11/16 Message-ID: <%t_Q5.1109$B65.23532@m2newsread.uni2.es> X-Deja-AN: 694534595 Content-Transfer-Encoding: 8Bit Content-Type: text/plain; charset=ISO-8859-1 X-Complaints-To: abuse@wanadoo.es X-Trace: m2newsread.uni2.es 974418939 62.36.188.151 (Fri, 17 Nov 2000 00:55:39 MET) Organization: Servidor Usenet News de Uni2/Wanadoo Mime-Version: 1.0 User-Agent: KNode/0.3.3 NNTP-Posting-Date: Fri, 17 Nov 2000 00:55:39 MET Newsgroups: es.comp.os.linux.programacion