}I would like to pass the name of a file from a C program to a script file.
}I know i could normally do it with
}
}name=`myprog`
}echo $name
}
}The problem is that myprog is an interactive program using curses whcih calls
}for user input.
}Is there any solution to this problem.
Is this too yucky?
------------- /tmp/ftest.sh ---------------------------------------------------
#!/bin/sh
/etc/mknod /tmp/fifo$$ p
/tmp/ftest /tmp/fifo$$ &
fname=`cat /tmp/fifo$$`
/bin/rm -f /tmp/fifo$$
echo filename is $fname
exit 0
--------------- /tmp/ftest.c --------------------------------------------------
#include <stdio.h>
#include <sys/file.h>
#define FILENAME "/tmp/jibberish"
int main(argc, argv)
int argc;
char ** argv;
{
int fd;
if (argc != 2) {
fprintf(stderr, "no fifoname, you're screwed!\n");
exit(1);
}
if ((fd = open(argv[1], O_WRONLY, 0666)) < 0) {
fprintf(stderr, "can't open %s, you're screwed!\n", argv[1]);
perror("open");
return (1);
}
if (write(fd, FILENAME, strlen(FILENAME)) != strlen(FILENAME)) {
fprintf(stderr, "can't write %s, you're screwed!\n", argv[1]);
perror("write");
return (1);
}
(void)close(fd);
printf("Everything went groovy, dude!\n");
return (0);
Quote:}
----------------- begin output ------------------------------------------------
% /tmp/ftest.sh
Everything went groovy, dude!
filneame is /tmp/jibberish
----------------- end ---------------------------------------------------------
You could use a real file too, but that would be boring... :)
John
--
John Hascall ``An ill-chosen word is the fool's messenger.''
Systems Software Engineer
Project Vincent
Iowa State University Computation Center + Ames, IA 50011 + 515/294-9551