The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
.
google unix.com


High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
simple awk question orahi001 UNIX for Dummies Questions & Answers 2 01-11-2008 10:16 AM
Ok simple question for simple knowledge... Corrail UNIX for Dummies Questions & Answers 1 11-28-2005 01:03 PM
Simple FTP question fundidor UNIX for Dummies Questions & Answers 2 04-28-2005 10:59 PM
a very simple question (but i don't know) dell9 High Level Programming 1 10-30-2001 03:37 AM
Simple question? Cuthbert UNIX for Dummies Questions & Answers 5 07-16-2001 02:00 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 12-13-2006
Xeed Xeed is offline
Registered User
  
 

Join Date: Dec 2006
Posts: 4
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 (permalink)  
Old 12-13-2006
Corona688 Corona688 is offline
Registered User
  
 

Join Date: Aug 2005
Location: Saskatchewan
Posts: 1,942
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 (permalink)  
Old 12-13-2006
Xeed Xeed is offline
Registered User
  
 

Join Date: Dec 2006
Posts: 4
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 (permalink)  
Old 12-13-2006
Corona688 Corona688 is offline
Registered User
  
 

Join Date: Aug 2005
Location: Saskatchewan
Posts: 1,942
Without more details, or the code in question, I don't know.
  #5 (permalink)  
Old 12-14-2006
Xeed Xeed is offline
Registered User
  
 

Join Date: Dec 2006
Posts: 4
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 (permalink)  
Old 12-14-2006
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,763
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?
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 05:41 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.

Content Relevant URLs by vBSEO 3.2.0