LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 12-15-2004, 10:02 AM   #1
belorion
Member
 
Registered: Aug 2003
Distribution: Slackware 10.0
Posts: 124

Rep: Reputation: 16
Basic piping issue


I have a program, foo.exe, that takes a file name as input:

$> ./foo.exe myfile.txt

I need to replace the first line of this file using sed, but I don't want to write it out this new file since it is about 1gig in size (and I can't just go in to edit the original, I don't have permission).

So I thought, why not just pipe it?

However, I haven't gotten it to work yet. This is what I tried:

$>sed -e '1s/old/new/' myfile.txt | foo.exe -o myoutput

My program, foo.exe, gives me the "help" showing usage because it isn't seeing my input file. What am I doing wrong?
 
Old 12-15-2004, 10:12 AM   #2
320mb
Senior Member
 
Registered: Nov 2002
Location: pikes peak
Distribution: Slackware, LFS
Posts: 2,577

Rep: Reputation: 48
do you have read permission to foo.exe ??

if not then your script won't work.......!!
 
Old 12-15-2004, 10:14 AM   #3
belorion
Member
 
Registered: Aug 2003
Distribution: Slackware 10.0
Posts: 124

Original Poster
Rep: Reputation: 16
I have full permissions on foo.exe, I only have read permission on the input file. But I need to change the first line of this input file, which is 1gig+ (so I don't want to have to write it out.)
 
Old 12-16-2004, 07:07 PM   #4
AnanthaP
Member
 
Registered: Jul 2004
Location: Chennai, India
Posts: 952

Rep: Reputation: 217Reputation: 217Reputation: 217
first of all, Foo.exe looks like a specific program that takes one argument as the input file. Obviously, it doesn't accept nil arguments and default to stdin. Also the argument expected may be thge name of an existing file and then you might have no option but to write it to a file first.

Please try
foo.exe `sed -e '1s/old/new/' myfile.txt`

The sed should get evaluated first and then the result passed to foo.exe.

If it still doesn't work, then you have to write it to a file or else get the programmer to provide for reading from srtdin if argv(1) = "-" - say.

End
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with piping mijohnst Linux - General 7 10-21-2005 04:14 PM
basic piping problem corck Programming 4 08-01-2005 03:30 AM
wget issue, basic but typical emailssent Linux - Newbie 3 03-03-2005 03:22 PM
linksys 32mb usb key - basic kernel issue d_t_baker Linux - Hardware 1 10-23-2003 04:44 AM
I'm a BASIC chap, looking for some info on BASIC programming CragStar Programming 2 01-21-2001 09:19 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:18 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration