[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: shell



What kind of values are you passing to the script?
You realize the shell expands wildcards before they 
hit the script, right?

Try tracing execution.  Put a "set -x" at the beginning
of the macro and check the output.  (see my mods below):

--------------------------------------------
Bruce Smith                bruce@armintl.com
System Administrator / Network Administrator
Armstrong International, Inc.
Three Rivers, Michigan  49093  USA
http://www.armstrong-intl.com/
--------------------------------------------


> I have shell problem in a shell script that I can't explain. And it is getting worse, ...  how longer I think about it how less I
> understand.
> 
> ....
> #----------------------------------------------------------------
> # define macro
> #----------------------------------------------------------------
> #
> extensie()
> {
> # make IFS a line feed
> IFS='
> '

# turn on tracing
set -x


>         for i in `ls -1 $1`
>         do
>                 echo "["$i"]"
> 
>                 ls "${1}/${i}"
>                 type "${1}/${i}"
>         done

# turn off tracing
set +x


> }
> 
> extensie $1
> ...
> 
> This is part of a much larger script to detemine attachment file types and it is called with the name of the directory where all
> attachments are placed for (virus) scanning. Problem is that the "type" command always returns a "file not found"  while the "ls"
> does not.  I need to set the IFS because of the many spaces used in attachment names. eg. "this a example.txt" instead of
> "this_is_a_example.txt". Leaving the IFS unchanged would give breaks at every space.
> 
> Does anyone have an idea why the 'ls' finds the files and the 'type' does not? Using type on the command prompt does work.
> 
> TIA
> Bert.