Post Closed as "duplicate" by Kusalananda bash of
2 Removed often-misinterpreted tag
source | link

How can iI make a bash counter script work when executing it from another script?

I have a script that uses wget and saves the output to a file with a name of an incrementing variable.

Counter.sh:

number=1
for i in $(cat file)
do
wget $i -S -O $number.html 2>&1
((number++))

sleep 1   
echo 'done'

done

I can run the script from the command line and it operates perfectly. However when iI execute it from within another script:

Script 2:

./counter.sh

iI receive the following output:

scripts/counter.sh: 5: scripts/counter.sh: number++: not found
done
scripts/counter.sh: 5: scripts/counter.sh: number++: not found
done
scripts/counter.sh: 5: scripts/counter.sh: number++: not found
done
scripts/counter.sh: 5: scripts/counter.sh: number++: not found
done

For some reason the counter ++ is not working when executed from within another script. How can iI fix this?

How can i make a bash counter script work when executing it from another script?

I have a script that uses wget and saves the output to a file with a name of an incrementing variable.

Counter.sh:

number=1
for i in $(cat file)
do
wget $i -S -O $number.html 2>&1
((number++))

sleep 1   
echo 'done'

done

I can run the script from the command line and it operates perfectly. However when i execute it from within another script:

Script 2:

./counter.sh

i receive the following output:

scripts/counter.sh: 5: scripts/counter.sh: number++: not found
done
scripts/counter.sh: 5: scripts/counter.sh: number++: not found
done
scripts/counter.sh: 5: scripts/counter.sh: number++: not found
done
scripts/counter.sh: 5: scripts/counter.sh: number++: not found
done

For some reason the counter ++ is not working when executed from within another script. How can i fix this?

How can I make a bash counter script work when executing it from another script?

I have a script that uses wget and saves the output to a file with a name of an incrementing variable.

Counter.sh:

number=1
for i in $(cat file)
do
wget $i -S -O $number.html 2>&1
((number++))

sleep 1   
echo 'done'

done

I can run the script from the command line and it operates perfectly. However when I execute it from within another script:

Script 2:

./counter.sh

I receive the following output:

scripts/counter.sh: 5: scripts/counter.sh: number++: not found
done
scripts/counter.sh: 5: scripts/counter.sh: number++: not found
done
scripts/counter.sh: 5: scripts/counter.sh: number++: not found
done
scripts/counter.sh: 5: scripts/counter.sh: number++: not found
done

For some reason the counter ++ is not working when executed from within another script. How can I fix this?

1
source | link

How can i make a bash counter script work when executing it from another script?

I have a script that uses wget and saves the output to a file with a name of an incrementing variable.

Counter.sh:

number=1
for i in $(cat file)
do
wget $i -S -O $number.html 2>&1
((number++))

sleep 1   
echo 'done'

done

I can run the script from the command line and it operates perfectly. However when i execute it from within another script:

Script 2:

./counter.sh

i receive the following output:

scripts/counter.sh: 5: scripts/counter.sh: number++: not found
done
scripts/counter.sh: 5: scripts/counter.sh: number++: not found
done
scripts/counter.sh: 5: scripts/counter.sh: number++: not found
done
scripts/counter.sh: 5: scripts/counter.sh: number++: not found
done

For some reason the counter ++ is not working when executed from within another script. How can i fix this?