Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Read an input file and cat it to another file and exec it in unix

Status
Not open for further replies.

frywonton

Technical User
Aug 31, 2011
3
0
0
US
Hi Experts:

I am trying to write a simple unix script. I am pretty sure it can be done but I am having issue with it. I am trying to write a unix script when user enter a file, cat the file and another file to create another file an then exec it/run.
Here is a sample of my script(test.sh):
#!/bin/sh
InFile=`myinfo.info`

while read line
do
echo $line
exec cat $FILE add_info.inf > all_info.sh
done < $InFile
exec ./all_info.sh


When I run this, it ./test.sh, I got this error message:
./test.sh: line 2: ./myinfo.info: Permission denied
./test.sh: line 8: $InFile: ambiguous redirect

Also how do I print on the screen to see content of the file?
Any insight on what I am doing wrong is greatly appreciated.

Thanks in advance.
 
Hi

Your question has nothing to do with Tcl/Tk. Re-post it in forum822 and red-flag this thread asking the site management to remove it as off-topic.

Before posting it again, read the Substitution ( or Command Substitution ) section in your shell's man page, then think about the first error you got ( the one complaining about line 2 ). Regarding the use of [tt]exec[/tt], better forget it.


Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top