[SOLVED] <<EOT to program in different directory

Hello, I am new to shell scrip. I have written a .sh file that goes

 ./myprogram << EOT
14
file.name
EOT

and works as expectecd - it passes 14 and file.name to the program being run as it askes for command line input. When I try and keep myprogram in a different directory and do the same thing I use

 PROGRAMS=$HOME/here/lives/code 
$PROGRAMS/myprogram << EOT
14
file.name
EOT

myprogram launches fine, but the variables 14 and file.name are not passed to myprogram as they were before. I am afraid I am stumped, and do not seem to be able to find the answer, but I suspect is is because I do not know the right terms to search for to solve this. Any help would be wonderful Thanks Jimbo

What Operating System and version are you using?
What Shell are you using?

The script looks ok in Posix Shell.

Maybe myprogram behaves differently if it is run from a different directory. Try running myprogram interactively from the command line using:

$HOME/here/lives/code/myprogram

Does it behave the same way as it does if you run:

cd $HOME/here/lives/code
./myprogram

@mobitron
Good thinking.
Perhaps the parameter "file.name" needs the full path if "file.name" resides in $HOME/here/lives/code .
Issuing the "cd" first is a better idea.

Everyone, thanks for the quick replies

so, I ran

-------------------- 
#!/bin/sh 

P=/bin 

$P/cat << EOT 
hello 
world 
EOT 

cat << EOT 
hello 
world 
EOT 
-------------------- 
And I get the output: 
-------------------- 
>./test.sh 
hello 
world 
hello 
world 
> 
-------------------- 

which is as expected, so looked harder at the code and mobitron hit it on the head. The problem was an issue overwriting files in that directory (hardcoded rather than user permissions which is why I dismissed it and assumed my scripting was at fault). Simple line of code and all fixed

Thanks for the help, without your suggestions I would still be banging my head against a wall!

Jimbo