Skip to main content

All Questions

Tagged with
7 votes
3 answers
676 views

How would you gracefully handle this snippet to allow for spaces in directories?

I have a series of commands, e.g.: ssh -i key 10.10.10.10 mkdir -p "${DEST_PATH}/subdir1" "${DEST_PATH}/subdir2" rsync "${SOURCE_PATH}" "$DEST_HOST:${DEST_PATH}/...
JoeSlav's user avatar
  • 128
15 votes
3 answers
4k views

How do ssh remote command line arguments get parsed

I've seen the questions and answers about needing to double-escape the arguments to remote ssh commands. My question is: Exactly where and when does the second parsing get done? If I run the ...
onlynone's user avatar
  • 636
0 votes
1 answer
797 views

Date command is not working in remote server when running using a script

I am running below command from a script from a remote server, but getting error No such file or directory ssh -t -t [email protected] \"sudo mysql nss_mysql < /home/user/scripts/Db_nss_mysql-`date ...
prado's user avatar
  • 940
0 votes
1 answer
2k views

mask Dollar, brackets and quotes in remote ssh command [duplicate]

I want to do some script on a remote mashine through ssh: ssh Server "V=\$\(lua -e 'print\(require\(\\\"platform_info\\\"\).get_image_name\(\)\)'\); echo \$V" But this echo $V at the end gives me ...
rubo77's user avatar
  • 29.4k
0 votes
3 answers
1k views

issue with back quotes inside while loop when running a command over ssh

This question is a bit complicated. I will try to explain in detail. I have two machines, one is local and other say 192.168.1.2. I have set the following variables in my local machine CHECK="/home/...
Anonymous Platypus's user avatar
2 votes
2 answers
5k views

How to escape quotes in shell within both usage of ssh and sudo?

In one word: question and example could test locally: sh -c "echo 'how to print single quote here'" details: I have a config like this: upload_server = ('192.168.1.1', 10051) now I need a shell ...
jixiang's user avatar
  • 121
2 votes
2 answers
273 views

Multiple commands with quotations after SSHing

I have a server I have to ssh into with many commands which feature the use of variable assignment and consequently a lot of quotation marks. If we consider the script: ssh user@host "kinit -k -t /...
Nanor's user avatar
  • 195
2 votes
1 answer
1k views

Syntax error with variable containing quotes

I have a bunch of Linux machines behind 2 gateways. To connect to set one I do ssh -o ProxyCommand="ssh gateway1 nc %h %p" machines_behind_1 ssh -o ProxyCommand="ssh gateway2 nc --proxy %h %p --...
Hari Sundararajan's user avatar
1 vote
1 answer
2k views

Run for loop via ssh

Good day All, I'm attempting to run a for loop via SSH. The loop is used to get the last login of each user that has an account on the server, ssh 172.20.2.1 '''for i in `cat /etc/passwd | awk -F: '{...
jasmaar's user avatar
  • 305
6 votes
3 answers
4k views

Passing multiple of arguments with whitespaces through a script to ssh

I want to remove multiple files from remote server. I have all files under one array in a script and I call other script which will remove files. Let output of "${b[@]}" is: /mnt/DataBK/...
AVJ's user avatar
  • 505
3 votes
2 answers
3k views

ssh me@remote "<script with a for loop and variables>" - problem with variable expansion in for loop in remote script

Note - I posted a similar question yesterday and got a bit further thanks to @cas but am still having problems. I've refined the question so have re-asked it. I'm passing script text to an ssh ...
Max's user avatar
  • 61
3 votes
2 answers
6k views

Passing script string to ssh from within a bash script function - variable evaluation problem

I'm trying to write a bash script that runs a remote script via ssh as below: #!/bin/bash logfilepattern="*drupal*.gz php*.gz error*.gz" function getlogcounts { echo "in getlogcounts" echo $...
Max's user avatar
  • 61
3 votes
1 answer
391 views

View remote value of $PATH inside shell script

When executing this bash script, it only shows my local path. ssh ${REMOTE_HOST} 'bash -s' <<EOL set -e source ~/.profile echo $PATH # Commands here don't work because $PATH is ...
Flash's user avatar
  • 133
0 votes
2 answers
2k views

Exclude the output from ssh and only log the error if found

typeset -f | sshpass -e ssh -o StrictHostKeyChecking=no user@${IPADDRESS} " $(cat); IFERROR=$(checkscript); echo "$IFERROR"" > ${SSHTEMPFILE} 2>&1 This line...I can't exclude the "...
Vianymoon's user avatar
1 vote
2 answers
3k views

ssh inside a script with 'command' instead of "command"

I am trying to run commands on various nodes of our cluster automatically via a simples script. I have seen that I can run: #!/bin/bash echo "Machine: "$HOSTNAME; ssh machine2 'echo Machine: $...
drjrm3's user avatar
  • 2,085

15 30 50 per page