The job/script will not inherit remote environment attributes unless you use nexec to execute it.
Even then, be sure to use the -l option (l as in "login"). This will attempt to log your nexec session into the remote server, running various init scripts and better setting your remote environment correctly.
I am not sure that I can enter the -l option in this situation.
This is pre and post commands as part of a file deploy job.
The problem arises from the fact that root's home directory is not always /
On some boxes it is /root, others it is /home/root and others it is just /
I originally tried to do cp filename ~root
It does not understand the tilde expansion process of a shell to determine that this is the home directory of user root.
I then tried to do simply cd
Because the jobs are running as root, it should have gone to root's home dir.
I could have then copied the files by doing cp /tmp/blade/filename .
This did not work so I did the env > filename and found that even the $HOME environment variable was not getting set to the proper value from the /etc/passwd file.
What about trying a
sh -c "cp filename ~root"
? Would that initialize the environment properly?
That did the trick.
You can also use:
cd $(grep ^root: /etc/passwd | cut -d : -f 6)
Wrap the username in ^ and : to keep from matching substrings.