Reputation: 3
ssh xxx@remote_system " echo $dateVar; date=$dateVar"
I am trying to pass dateVar
to the remote system from within the shell script, which I believe works fine and then trying to set the date on the remote server to that of the dateVar
variable, but with no success. Can someone please help?
Regards!
Upvotes: 0
Views: 1905
Reputation: 7703
From date man page, to set date using the date
command you should do date --set=$dateVar
. Therefore, in order to change date on a remote system, executing the following should suffice:
ssh xxx@remote_system "sudo date --set=$dateVar"
Upvotes: 1
Reputation: 92316
Assuming the date format is correct, you need to remove the =
since it creates/sets a variable named date
instead of calling the command date
:
ssh xxx@remote_system "date $dateVar"
Your user xxx
might not have the necessary rights, so you might set up sudo
(google for things like sudo
and /etc/sudoers
) so you can do:
ssh xxx@remote_system "sudo date $dateVar"
Upvotes: 0