I'm trying to ssh into a server and get the system uptime using a specific command but it's failing to execute.
this would work locally on almost all unix systems
startuptime=`uptime | awk '{print $2,$3,$4,$5}'` && startuptime1=${startuptime%,} && startdayshours=${startuptime1%%:*}' Hours, ' && startminutes=${startuptime1##*:}' Minutes' && echo 'System Uptime -' $startdayshours$startminutes `date`
but if i do this, it won't work ( no matter how i change/add escape chars or $() or `` or ' " ' " ' quotes etc..)
ssh user@server "startuptime=`uptime | awk '{print $2,$3,$4,$5}'`; startuptime1=${startuptime%,}; startdayshours=${startuptime1%%:*}' Hours, '; startminutes=${startuptime1##*:}' Minutes'; echo 'System Uptime -' $startdayshours$startminutes `date`"
P.S: i know it won't work with quotes cuz i need to escape the inner ones but it's just an example like ssh user@server command_goes_here