LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-16-2004, 01:58 PM   #1
ericcarlson
Member
 
Registered: Jan 2002
Posts: 161

Rep: Reputation: 30
Stupid bash problem


Feduppa C2 Final ;-)

I need to get the text from a file to be passed into a shell script from another shell script. Each permutation I try fails, and I've never eally got to grips with this even though I know you guys eat & sleep it.

The first script is called data.sh:
#!/bin/sh
./process.sh < `cat value.txt`

(thats my attempt at fixing it - it gives "no such file or directory")

The target script is called process.sh:
#!/bin/sh
echo processing $1

The file value.txt contains "bingo!"
So I just want to see "processing bingo!". Heeelp!!
 
Old 07-16-2004, 04:16 PM   #2
btmiller
Senior Member
 
Registered: May 2004
Location: In the DC 'burbs
Distribution: Arch, Scientific Linux, Debian, Ubuntu
Posts: 4,284

Rep: Reputation: 371Reputation: 371Reputation: 371Reputation: 371
What you wrote works fine for me. Are you sure value.txt is in the same directory you're running the script from and is readable by your user?
 
Old 07-16-2004, 07:54 PM   #3
osvaldomarques
Member
 
Registered: Jul 2004
Location: Rio de Janeiro - Brazil
Distribution: Conectiva 10 - Conectiva 8 - Slackware 9 - starting with LFS
Posts: 519

Rep: Reputation: 34
Mr. ericcarlson,

I created your environment in my machine. When I started the script, I got
Code:
Modelo:~/teste# data.sh
./data.sh: bingo!: no such file or directory
It's saying "the file bingo! does not exist". Lets see what happened. When you use the input redirector "<" you are saying to the shell read the contents of the file, in this case, "`cat value.txt`". Then, first the shell executes the redirection specified by the grave signals, substituting the expression by the resulting content. So, now you have a command like
Code:
./process.sh < bingo!
This file doesn't exist. Besides you want to pass the file contents as a parameter to the process.sh. You need to remove the redirector "<". So, your command, after the substitution will be
Code:
./process.sh bingo!
I hope it helps.
 
Old 07-17-2004, 03:19 AM   #4
ericcarlson
Member
 
Registered: Jan 2002
Posts: 161

Original Poster
Rep: Reputation: 30
Yes!!

Thats it! I even understand it too - nice explanation.
Thanks for everyones help - this forum is too cool :->
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Stupid, stupid question; I lost Klaptop. :( Surfrider Slackware 2 08-31-2005 10:12 PM
My Last Stupid Problem mtecknology Linux - Software 8 07-15-2005 04:32 PM
Stupid problem k1ll3r_x Linux - Hardware 4 01-06-2005 09:21 AM
stupid bash question tisleti Linux - Newbie 4 09-10-2004 06:34 AM
bash script - even more stupid question than last time. webamoeba Linux - Newbie 2 02-12-2004 04:03 AM


All times are GMT -5. The time now is 01:02 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration