Click to See Complete Forum and Search --> : can't substitute file name in a script....


802.11
08-06-2003, 10:15 AM
#!
#set -x
clear
$1 = Myfile.txt
echo "$1"
while read LINE
do
cat "$1"


done < "$1"
echo "completed"


can u correct my script ,please!


thanks!

andysimmons
08-06-2003, 10:25 AM
I'm away from a linux box right now, but right off the bat I can tell you not to use $ on the left hand side of the variable assignment...I think 1="MyFile.txt" is what you need. I don't think you want quotes when you're echoing or catting stuff either.

802.11
08-06-2003, 07:08 PM
I am using rh 9.0

#!
#set -x
clear
var = "Myfile.txt"
echo $var
while read LINE
do
cat $var | echo $LINE

done < $var
echo "completed"
~

but the feeback
./test: line 4: var: command not found

./test: line 10: $var: ambiguous redirect
completed

andysimmons
08-07-2003, 01:35 AM
I don't think I've ever put spaces in an assignment (i.e. var="Myfile.txt") but I don't know if that would mess it up. I'm one of the worst scripters alive, but hopefully someone smart will run across this thread soon. Otherwise I'll tell you tomorrow when I can try it myself.

802.11
08-07-2003, 04:41 AM
I need to do pause whenever its counter up to 100, but I do not the shell
command for 'pause a while', I try to man a few like break/halt/wait. I am
not sure for the moment. can u guild me? please!



if [ "$i" -eq 10 ]; then
echo "$i";
#break 2
continue
fi

chrism01
08-07-2003, 07:56 AM
man sleep

bwkaz
08-07-2003, 08:05 PM
Turn this:

#!

into this:

#!/bin/sh

or this:

#!/bin/bash

As it is, your kernel won't be able to figure out which interpreter to use.

You also cannot have spaces around variable assignments, as andysimmons suspected. The quotes, however, won't matter unless the stuff in them has spaces in it. If spaces are in it, then you will need the quotes. If no spaces are in it, then they won't matter.

802.11
08-09-2003, 08:53 AM
yes, i will try it. thanks!