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
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
@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.
--------------------
#!/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!