How can I determine missing excape characters from current string command from master to remote server via SSH?
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:
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.
Need some advice on how I can run similar string directly on remote server on this master server as well via ssh.
* BashProgrammingShell ScriptingUnix OS
Last Comment
skullnobrains
8/22/2022 - Mon
Kent Olsen
Hi AXI25,
If either {current_date} or {passwd_expire} is blank, you'll get an empty substitution and the date function won't work. Are you sure that they're set on the remote server?
Run the command through "echo" to see what text will be executed.
The date command in AIX is much more limited that date on other systems.
I can't get it to execute on my local AIX system, much less a remote one. I'm getting the same errors that you are. The date function is the culprit.
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
Kent Olsen
The date command in AIX will set the date, or display the current date in any of many formats.
You cannot pass a date value to the date command and have it reformat it. That appears to be what you're trying to do.
AIX25
ASKER
On this particular example I am currently testing this on Redhat Linux, but same errors as you're pointing out. I was able to run just the reformat portion also remotely, that wasn't an issue, when trying to narrow it down. It appears when I try to calculate the delta and the arithmetic portion it's clobbering out. I can get the date format returned fine. What I will try next is either running a script local to the remote server and then copy data back. Or, I'll try to collect the dates locally on the master server and do the arithmetic there.
It would be nice to have it done through one SSH string command, but I have other methods that seem to be working.
Kent Olsen
Ahhh....
Based on your user I assumed that this was an AIX issue. :)
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
Thank you, both. As I didn't create my script as mentioned by skullnobrains, I was still running into same issue, it did make sense that it's running command locally. What I ended up doing as example to work was the idea of it running it remotely as a whole script instead of it remotely through SSH. Collects the data on the remote server and just copies it back to master. It's running over 500 plus servers and doing it as multi-threaded.
#!/bin/bash
# This is local script on master server
If either {current_date} or {passwd_expire} is blank, you'll get an empty substitution and the date function won't work. Are you sure that they're set on the remote server?
Run the command through "echo" to see what text will be executed.
echo ${server} "echo $(( ($(date --date="$(echo ${passwd_expire})" +%s) - $(date --date="$(echo ${current_date})" +%s) )/(60*60*24) ))"
Try with the variables set and empty to see the difference.