Troubles inside an envelope function

Hi all!

I have a function (named "orig") that analyze web sites given from an argument, it works very well when by itself:

#!/bin/bash

chain="$1"
echo chain $chain

curl "$chaine" -o prop.txt
...
and then it perform some analysis on the prop.txt

It works flawlessly if I type:
orig (followed by a proper URL

The issue I have is that, to speed up thing, I have generated a list of URL in a file named "file.txt".

I put them in an old envelope function (that always worked in the past) that goes thought the list in file.txt:

#!/bin/bash
while read curline; do
eval $1 $curline;
done < /file.txt

Hi all!

I have a function (named "orig") that analyze web sites given from an argument, it works very well when by itself:

#!/bin/bash

chain="$1"
echo chain $chain

curl "$chaine" -o prop.txt
...
and then it perform some analysis on the prop.txt

It works flawlessly if I type:
orig http...

The issue I have is that, to speed up thing, I have generated a list of URL in a file named "file.txt".

I put them in an old envelope function (that always worked in the past) that goes thought the list in file.txt:

#!/bin/bash
while read curline; do
eval $1 $curline;
done < /file.txt

I type :
envel orig

I get:
chain http...(correct URL)
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
curl: (56) Failure when receiving data from the peer

I see the argument is perfectly read but the curl stopped to perform as it does when I use it outside my old envel.

 tags will help us.


#!/bin/bash

chain="$1"
echo chain $chain

curl "$chaine" -o prop.txt
  1. You misspelled the variable. Is that how it appears in your code?
#!/bin/bash
while read curline; do
eval $1 $curline;
done < /file.txt
  1. You really ought to put $curline in double-quotes.

  2. "/file.txt" probably should be simply "file.txt" without the preceding slash.

Thank you! The double quotes did the trick!