- in_from_stdin = get_line_from_file(stdin);
- for (;in_from_stdin!=NULL;) {
- char *tmp;
- opt = strlen(in_from_stdin);
- len_args += opt + 3;
- args=xrealloc(args, len_args);
-
- /* Strip out the final \n */
- in_from_stdin[opt-1]=' ';
-
- /* Replace any tabs with spaces */
- while( (tmp = strchr(in_from_stdin, '\t')) != NULL )
- *tmp=' ';
-
- /* Strip out any extra intra-word spaces */
- while( (tmp = strstr(in_from_stdin, " ")) != NULL ) {
- opt = strlen(in_from_stdin);
- memmove(tmp, tmp+1, opt-(tmp-in_from_stdin));
+ while ((file_to_act_on = get_line_from_file(stdin)) !=NULL) {
+
+ FILE *cmd_output = NULL;
+ char *output_line = NULL;
+ char *execstr = NULL;
+
+ /* eat the newline off the filename. */
+ if (file_to_act_on[strlen(file_to_act_on)-1] == '\n')
+ file_to_act_on[strlen(file_to_act_on)-1] = '\0';
+
+ /* eat blank lines */
+ if (strlen(file_to_act_on) == 0)
+ continue;
+
+ /* assemble the command and execute it */
+ execstr = xcalloc(strlen(cmd_to_be_executed) +
+ strlen(file_to_act_on) + 1, sizeof(char));
+ strcat(execstr, cmd_to_be_executed);
+ strcat(execstr, file_to_act_on);
+ cmd_output = popen(execstr, "r");
+ if (cmd_output == NULL) {
+ perror("popen");
+ exit(1);