How do I get a command like "ssh Theuser@host date" to execute the /home/Theuser/.profile before executing the "date" command?
try using ssh -t
or . ~/.profile;date
Thank you Frank
the -t works fine... now for part 2 please
if the profile is designed for tty input (ex Please specify test or production?") how can I
a) pass an answer via teh ssh command
and/or
b) request that ssh command ignore "reads"
Thanks again
you can do either but if you want to read input from the user then -t would be required. you can also try the ssh -n option
or a better long term solution - put this in your .profile if you don't use -t
if tty -s
then
echo "blah blah blah"
read blah
fi
-n Redirects stdin from /dev/null (actually, prevents
reading from stdin). This must be used when ssh is run
in the background. A common trick is to use this to
run X11 programs on a remote machine. For example,
ssh -n shadows.cs.hut.fi emacs &
will start an emacs on shadows.cs.hut.fi, and the X11
connection will be automatically forwarded over an
encrypted channel. The ssh program will be put in the
background. This does not work if ssh needs to ask for
a password or passphrase. See also the -f option.)
I shall try your suggestions....
---------- Post updated 01-09-11 at 01:06 PM ---------- Previous update was 01-08-11 at 11:03 PM ----------
Ok tried all teh above still no go
I can get commands to run before the shell is kicked off (~/.ssh/rc)
I can get environment variables set (~/.ssh/environment and sshd_config changes0
but I cannot get the user .profile to run for a user with a ssh Theuser@host date
even using the ssh options (albeit good) that Frank suggested.
For reasons that can get complicated (MVS is really shooting off the AIX command to AIX) I cannot use the option of physically executing teh users profile as in the suggestion
ssh Theuser@host ". ~/.profile;date"
ssh
is date the real command your using or are you running a script or other program? If it's a script then I suggest sourcing the .profile within the script or put the logic that is in .profile in the script.