I'm new to Bash and I have a problem that find difficult to solve, may be easy for some.
I have a really old SCO UnixWare 7 system with no SSH only RSH available. SCO doesn't exist anymore , I believe they are bankrupt. The box has been up for about 15 years never had a problem. We will move away from this platform in the summer however for now I need to copy some files to one of the Linux boxes and I'm trying to write a very short script. Please don't tell me that RSH is not secure since in this environment security is irrelevant. The UnixWare box and two other Linux boxes running CentOS 6 are dedicated and used by 3 people only to manage a number of barriers in a parking lot and not connected to the internet or any other network. Just 3 servers, connected to a 4 port standalone switch nothing else connected
I run this command on the Unixware server to set the variable on Linux1 running CentOS 6 with a formatted data and show the content:
rsh Linux1 "TEST=$(date --date='-9day' +%A_%B-%d_Backup); echo \$TEST"
I get this error
# rsh Linux "TEST=$(date --date='-9day' +%A_%B-%d_Backup); echo \$TEST" UX:date: ERROR: Illegal option -- - UX:date: ERROR: Incorrect usage UX:date: TO FIX: Usage: date [-u] [+format] date [-u] [[mmdd]HHMM | mmddHHMM[[cc]yy]] date [-a [-]sss.fff]
If I go to Linux2 also running CentOS 6 and run the same exact command against Linux1 I have no errors
[Linux2 ~]# rsh Linux1 "TEST=$(date --date='-9day' +%A_%B-%d_Backup); echo \$TEST" Wednesday_January-14_Backup
Why is the command not working when ran from the UnixWare server? It seems that Unixware doesn't pass the string to Linux1 to process but tries to process it locally (there is no
--date option on that ancient Unixware box, hence the error).