tomk@ur-laser.UUCP (08/23/84)
#include<stdio.h>
#include<math.h>
#include<sys/wait.h>
int dim_data[1][2]={ {250,250} };
char *aperatures[1]= { "1 1 4 a 4 a" };
main()
{
int speed;
char command[64],foo[64];
sprintf(command, "scanregion -da %s %d %d %d /dev/null",aperatures[0],
dim_data[0][0], dim_data[0][1], speed );
sprintf( foo,"echo \"%s \" >>result",command);
printf("%s\n", foo);
sprintf( foo, "time %s >>result 2>&1",command);
printf("%s\n", foo );
}
this Program produces the following output:
echo "scanregion -da 1 1 4 a 4 a 250 250 0 /dev/null " >>result
time >>result 2>&1
I believe it should produce something like:
echo "scanregion -da 1 1 4 a 4 a 250 250 0 /dev/null " >>result
time scanregion -da 1 1 4 a 4 a 250 250 0 /dev/null >>result 2>&1
Any ideas why this might not be so?
These are from a sun-150 with the Sun-2 CPU running Berkley 4.2
In what Sun calls there release 1.1.
--
--------------------------
Tom Kessler {allegra |seismo }!rochester!ur-laser!tomk
Laboratory for Laser Energetics Phone: (716)- 275 - 3786
250 East River Road 275 - 3194
Rochester, New York 14623
jim@ism780b.UUCP (08/27/84)
#R:ur-laser:-24200:ism780b:28500014:000:240 ism780b!jim Aug 25 16:13:00 1984 The string you sprintf'ed into foo is longer than 64 chars, which is all you allocated for foo. It overwrote command, which is next on the stack. Wasn't someone just complaining about sprintf? -- Jim Balter, INTERACTIVE Systems (ima!jim)