We help IT Professionals succeed at work.
Get Started

How can I determine missing excape characters from current string command from master to remote server via SSH?

179 Views
Last Modified: 2020-01-21
I am running into issue to determine escape characters from master to remote server over ssh.  I can return desired output on remote server with no issues.  Trying to run similar string on master server to remote server to get same result.

Below example is working fine on remote server and has expected results:

[root@remote_server ~]# echo ${passwd_expire}
Jun 17, 2020
[root@remote_server ~]# echo ${current_date}
Jan 09, 2020
[root@remote_server ~]# echo $(( ($(date --date="$(echo ${passwd_expire})" +%s) - $(date --date="$(echo ${current_date})" +%s) )/(60*60*24) ))
159

Open in new window


I would like to run those remotely and get same output, but I keep running into bash errors and I can't determine which escape character I could be missing or if it's execution process order is incorrect.

server=remote_server


[root@master ~]# echo ${passwd_expire}
Jun 17, 2020
[root@master ~]# echo ${current_date}
Jan 09, 2020
[root@master ~]# ssh -q ${server} "echo $(( ($(date --date="$(echo ${passwd_expire})" +%s) - $(date --date="$(echo ${current_date})" +%s) )/(60*60*24) ))"

Open in new window


Need some advice on how I can run similar string directly on remote server on this master server as well via ssh.
Comment
Watch Question
CERTIFIED EXPERT
Commented:
This problem has been solved!
Unlock 1 Answer and 9 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant

An Experts Exchange subscription includes unlimited access to online courses.

Get Started
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE