The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Reading specific contents from 1 input files and appending it to another input file sksahu Shell Programming and Scripting 5 01-14-2009 06:09 AM
Reading an Input file and searching for occurrences WIHOUT SED or AWK kartikkumar84@g Shell Programming and Scripting 2 05-08-2008 09:16 PM
Help reading an input file in KSH zilla30066 Shell Programming and Scripting 2 02-01-2007 06:45 AM
Script for reading an input file gzs553 Shell Programming and Scripting 1 10-17-2006 07:55 AM
Reading Input from File and Duplicates Output noelcantona Shell Programming and Scripting 6 10-18-2005 05:59 AM

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 01-07-2009
nadbar nadbar is offline
Registered User
  
 

Join Date: Jan 2009
Posts: 1
reading input from a file

I am trying to read input for a C program (that expects input from the user) from a file using the shell command:
progname < filename
but it seems that the program considers the char '<'
as the first input, hence causing an "error" in my program.
I checked it with another program and it seems to work properly.
any idea waht could be wrong?
  #2 (permalink)  
Old 01-07-2009
Franklin52 Franklin52 is offline Forum Staff  
Moderator
  
 

Join Date: Feb 2007
Posts: 4,345
Post your code within code tags.

Regards
  #3 (permalink)  
Old 01-07-2009
JerryHone JerryHone is offline
Registered User
  
 

Join Date: Nov 2006
Location: UK
Posts: 178
Are you :-
a) taking an argument on the command line and explicitly opening the filename specified in the program?
or
b) is your C program reading standard input?

From your description, it sounds like the program is written assuming (a) but you're attempting to run it assuming (b) i.e. the '<' is causing the shell to open the file and redirect it to your program as STDIN.

As Franklin52 says, a code fragment would clarify things.

Hope that helps.

Jerry
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 06:18 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.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0