/* ******************************************************************* * * * Copyright (c) L-DGO/MIT/JGOFS * * * * * * File : ex.c * * * * Purpose : * * * * Version Number : 1.2 * * * * Date Developer * * ---- --------- * * * * Sat Oct 17 1992 10.00 Glenn Flierl * * * * Revision History : * 22 May 08. WJS Include some .h files to get rid of compiler diagnostics Calculate the size of the com buffer and allocate that much (replaces fixed size 160 char buffer) Abort on some failures [begin 1.2] * * * * ******************************************************************* */ #include #include #include #include void ex_(stuff) char *stuff; { char *com; int bufsiz; /* "cd " longest getwd ";" \0 */ bufsiz = 3 + (PATH_MAX+1) + 1 + strlen(stuff) + 1; com = (char *)malloc(bufsiz); if (com == NULL) abort(); strcpy(com,"cd "); if (getwd(com+3) == NULL) abort(); strcat(com,";"); strcat(com,stuff); system(com); return; }