Skip to main content
The 2024 Developer Survey results are live! See the results

All Questions

Tagged with
2 votes
1 answer
10k views

Send variable with EOF and use host variable [duplicate]

I want to send variable from source to host, and exec host script. Here is my code : var1=1 ssh -p 42 root@xxx /bin/bash << EOF var2=2 echo $var1 echo $var2 EOF Return : 1 var1=1 ssh -...
callmemath's user avatar
0 votes
2 answers
2k views

If condition not working in script over ssh

Below shell script on SSH mode is not working. variable end_pos is getting value "Stop", but when it comes in IF loop , it doesn't check the condition and loop is getting failed. Output of command : ...
simplifiedDB's user avatar
0 votes
1 answer
205 views

ls -td fails to identify any directories

I'm having a bit of a problem working on a shell script. One of the commands within the script is used to push a set of commands from a Jenkins host to MySQL database hosts to run backups "locally" to ...
Josh Bonello's user avatar
3 votes
2 answers
9k views

How to copy files using scp from remote host when file have spaces

I need to copy a file from remote host to my local directory using scm where a file have spaces, for not I fixed the issue by ssh to that host and scp the file back. But I want to know how to copy ...
jcubic's user avatar
  • 10k
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
5 votes
2 answers
2k views

How to re-write this function to avoid argument injection

I have a function in my .bashrc file that allows me to run a script on a remote server with arguments via ssh. Currently, the function contains: function runMyScript { if [ $1 = "s3" ] then ...
cpd's user avatar
  • 153
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
0 votes
2 answers
815 views

Environment variables over ssh block in shell script [duplicate]

I have the following function : GetHostName () { NODE01_CHECK=`cat /etc/hosts | grep -w "node01" | awk '{print $1}'` NODE02_CHECK=`cat /etc/hosts | grep -w "node02" | awk '{print $1}'` IS_NODE1=`...
robertpas's user avatar
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
1 vote
4 answers
1k views

execute command over ssh connection [duplicate]

I want to excecute the following command over a ssh connection: tmpValue=$(cat /var/run/jboss-as/jboss-as-standalone8.pid) && top -b -U jboss -n 1 |grep $tmpValue |awk '{print $9}' This ...
LStrike's user avatar
  • 227
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
4 votes
2 answers
3k views

Why some commands don't load user environment when executed with ssh? (while other do)

On a target machine (OS X El Capitan) I have brew in /usr/local/bin. When I try to get brew's path I get no result: # ssh [email protected] -p 2222 which brew # Troubleshooting: brew is in /usr/...
techraf's user avatar
  • 5,981
2 votes
4 answers
760 views

Why does read with pipeline fail in an ssh session?

Why does this show blank lines instead of folders found by find? ssh -o stricthostkeychecking=no -o userknownhostsfile=/dev/null \ -o batchmode=yes -o passwordauthentication=no [email protected] \ ...
Guerraga's user avatar

15 30 50 per page