Executing a C program from a script
I currently execute a C program (example: /bin/cprogram) from a command prompt including passing a 600 character string within double quotes, and an output file name (example: /usr/outputfile).
Example: $ /bin/cprogram "very long string with spaces, special characters, but no double quotes, etc etc" /usr/outputfile Question: How would I write a shell script to receive that 600 character string and the output file name as input variables and then execute that same C program? |
I would suggest changing the cprogram to read from stdin.
That way the "600 character string" could be from a file, or a pipe... Much more flexible. But a shell script has exactly the same format as the command. |
This is what I've tried without success:
#!/bin/sh read input read filename /bin/cprogram $input $filename I include the double quotes on my input. Would that be lost somewhere? |
Yes, that would be lost where you use $input, put quotes around that
Code:
/bin/cprogram "$input" "$filename" |
All times are GMT -5. The time now is 01:12 AM. |