![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Rules & FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| simple awk question | orahi001 | UNIX for Dummies Questions & Answers | 2 | 01-11-2008 06:16 AM |
| Ok simple question for simple knowledge... | Corrail | UNIX for Dummies Questions & Answers | 1 | 11-28-2005 09:03 AM |
| Simple FTP question | fundidor | UNIX for Dummies Questions & Answers | 2 | 04-28-2005 06:59 PM |
| a very simple question (but i don't know) | dell9 | High Level Programming | 1 | 10-29-2001 11:37 PM |
| Simple question? | Cuthbert | UNIX for Dummies Questions & Answers | 5 | 07-16-2001 10:00 AM |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
Simple C question... Hopefully it's simple
Hello. I'm a complete newbie to C programming. I have a C program that wasn't written by me where I need to write some wrappers around it to automate and make it easier for a client to use. The problem is that the program accepts standard input to control the program... I'm hoping to find a simple way to modify the program to also accept input from a text file instead. Can someone please help me with this? I know my post is very vague, but hopefully someone can help guide me. Thanks.
|
| Forum Sponsor | ||
|
|
|
|||
|
You don't need to modify the program at all, since UNIX lets you redirect standard input to read whatever you please. A simple shell script wrapper can do this, for example:
Code:
#!/bin/sh exec /path/to/program < input_file.txt |
|
|||
|
It sounds like you may want a utility called expect - it lets you create fairly complex interactive dialogues with a program - from a script.
expect scripts are easier to create than C code... The here document - do you know what those are? Will they meet your needs? |
| Thread Tools | |
| Display Modes | |
|
|