Simple C question... Hopefully it's simple


 
Thread Tools Search this Thread
Top Forums Programming Simple C question... Hopefully it's simple
# 1  
Old 12-13-2006
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.
# 2  
Old 12-13-2006
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

# 3  
Old 12-13-2006
Unfortunately redirecting the input to get it from a file doesn't work. It answers the first question correctly, but the answers after that don't get the correct answers...
# 4  
Old 12-13-2006
Without more details, or the code in question, I don't know.
# 5  
Old 12-14-2006
I know it's hard to help me because I'm being so vague. I'm also having a hard time explaining exactly what I need to do without showing the code.
# 6  
Old 12-14-2006
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?
# 7  
Old 12-15-2006
Actually, I decided to take a few hours and read about C Programming. I figured out how to approach the code and found a solution. Thank you guys very much for the help.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Red Hat

Syslog.conf: looking for a simple answer on a simple question

Cheers! In /etc/syslog.conf, if an error type is not specified, is it logged anywhere (most preferable is it logged to /var/log/messages) or not? To be more precise I am interested in error and critical level messages. At default these errors are not specified in syslog.conf, and I need to... (6 Replies)
Discussion started by: dr1zzt3r
6 Replies

2. Shell Programming and Scripting

Help making simple perl or bash script to create a simple matrix

Hello all! This is my first post and I'm very new to programming. I would like help creating a simple perl or bash script that I will be using in my work as a junior bioinformatician. Essentially, I would like to take a tab-delimted or .csv text with 3 columns and write them to a "3D" matrix: ... (16 Replies)
Discussion started by: torchij
16 Replies

3. Shell Programming and Scripting

Simple if then else question

I am having trouble making this statement work. I am passing in a number value for the number of days to keep archive logs for and wanted to make sure that it is a number. I have a script that will return 1 for is a number and 0 for is not a number. I also want to make sure that the number is not... (2 Replies)
Discussion started by: gandolf989
2 Replies

4. Shell Programming and Scripting

Simple Question

Hi, Please don't berate me over the simplicity of these questions. I have recently gotten into bash shell scripting and enjoy it quite a bit. One thing I have not found the answer to though is when naming a shell script, what extension is normally used (ie myscript.?)? Also where is the standard... (5 Replies)
Discussion started by: msb65
5 Replies

5. Shell Programming and Scripting

Simple ls question

i am doing ls -la in the out put , first line is as total 41621 What is this total? (2 Replies)
Discussion started by: Saurabh78
2 Replies

6. Shell Programming and Scripting

Simple Question

If given some output such as: "I'm having a senior moment" How do you print the last six characters to the screen? I'm thinking with awk or sed but can't remember how. (1 Reply)
Discussion started by: stepnkev
1 Replies

7. UNIX for Dummies Questions & Answers

Very simple question

I'm new to unix commands and am wondering how you could create a page with html tags in it. echo "<b>Test</b>" > test.html doesn't work because of the tags. How would I do this. (4 Replies)
Discussion started by: roger19
4 Replies

8. UNIX for Dummies Questions & Answers

Ok simple question for simple knowledge...

Ok what is BSD exactly? I know its a type of open source but what is it exactly? (1 Reply)
Discussion started by: Corrail
1 Replies

9. UNIX for Dummies Questions & Answers

Simple Question

Can anyone tell me if there is a way to remove the encryption from Data CDs by UNIX? Or does anyone know of a program that can remove the encryption? I would much appreciate it! Thanks, -Peaves (2 Replies)
Discussion started by: Peaves
2 Replies

10. UNIX for Dummies Questions & Answers

Simple question

I am taking an intro to unix class and I can not figure out how to do part of the question. I am writing script to be exictued by a program in the tutoral. Question: Write every line containing the word ``delete'' produced by ``man mail'' into a file called ``delete''. Hint: What does using... (1 Reply)
Discussion started by: weathergirl
1 Replies
Login or Register to Ask a Question