Line works in solo but not in program?

Now I am just getting frustrated and confused... if anyone has some advice on how this anomoly is occurring I would greatly appreciate it.

cat helpme.txt | awk 'NR<5{printf("%-20s %-20d %-20d %-20.1f\n","hello",$1,$2,$3)}' | sort -rk4

This line works fine in solo - reads the three fields from helpme.txt and adds a first field "hello" before the others on output... seems simple enough and it works fine on its own on the command line.

In a small program it doesn't work...

#!/bin/sh

echo "Please enter the file you want compressed: \c"; read filename 

echo File: $filename

# check to see file exists and is readable with -r
if [ -r $filename ]
then

echo gzip | gzip -f $filename; gunzip -l $filename.gz > $filename.txt; gunzip $filename
gzip -f rose.bmp; gunzip -l rose.bmp.gz >> $filename.txt; gunzip rose.bmp.gz

cat helpme.txt | awk 'NR<5{printf("%-20s %-20d %-20d %-20.1f\n","hello",$1,$2,$3)}' | sort -rk4

else

echo sorry the file does not exist or is not readable

fi

So at this point I am thinking magic?

And yes with only the three fields in the short program it does work fine.

What is your default shell? When you are running command interactively? I think that might be a problem, because with this

#!/bin/sh

you are telling kernel to use sh to process your code and maybe your default shell is different

echo $0

might help you.

Regards,
Tayyab

The default is csh and the program runs sh - c shell and bourne shell

I'm beginning to wonder if I've somehow done something to my shell - one can change shell behaviour? Its just I use vpn to access the uni UNIX account and today I saw the same code operate correctly on the same UNIX environment while not in my account.

Does this make sense to anyone?

You mean same code doesn't work when you come thru VPN with same account, and it works with same account when you are directly connected to your network?

If code works with one account and doesn't work with other account, check login files for your csh, good luck.

sorry i meant the code works on the sys admin computer on the same unix system at the uni... but isn't working on my account.

I think I need to get them to set up a new account for me which works correctly. Thanks for the help.