All Questions
17
questions
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}/...
4
votes
1
answer
1k
views
Using a function's output (defined locally) inside SSH call
I have created a function
function getqueue() {
urlqueuename="urlcall"
ouput=`curl $urlqueuename`
queue=$(echo $ouput | jq -r '.queueName')
echo $queue
}
I am using a ssh call ...
4
votes
3
answers
7k
views
awk in ssh command line complains 'unexpected newline or end of string' How to resolve?
While running the below script had an issue, ^ unexpected newline or end of string
How could I resolve this ?
[root@emrbldbgdapd2 ~]# ./collectdata.sh
collect the data of 10.209.61.124
awk: cmd. ...
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 :
...
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 ...
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/...
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=`...
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 /...
1
vote
2
answers
4k
views
How to use single quotes inside ssh and sqlplus
Below script helps me to ssh and do sqlplus to fetch info from database. I checked and it worked well but the only problem is if i use single quotes in the sql query then I am getting an error since I ...
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/...
0
votes
2
answers
2k
views
how to run multiple commands with awk via ssh?
I am having difficulty on the command below. Something is not right with the awk command. I tried putting backslash but still no good.
Anyone can pin point where is my syntax gone wrong?
for i in $(...
2
votes
1
answer
3k
views
Run a command under sudo over SSH
I am accessing remote machine in Linux using Bash scripting.My code is as follows
#!/bin/bash
ssh -i manu_bp.pem [email protected] <<EOF
sudo -s
cat /opt/revsw-config/apache/...
2
votes
1
answer
3k
views
awk in ssh in su in a command substitution
I am creating a script that will ssh to a host and print all the user accounts and when they will expire.
On a host I can run awk -F':' '{ print $1}' /etc/passwd and it will give me a list of all ...
3
votes
1
answer
1k
views
Shell command works locally but does not get parsed correctly through ssh
If I execute the following shell command locally, I get the expected result:
adb -s 123456789 shell "su -c 'mount -o remount,rw /system;rm -r /system/app/MyApp.apk;cp /sdcard/MyApp.apk /system/...
3
votes
1
answer
561
views
Why do I get an error when double quoting single quotes in a script that launches a remote SSH command?
I have this script:
port=$1
cmd=$2
ssh [email protected] -p $port "'"$cmd"'"
When running myscript.sh 1000 "ls /dev/shm" it get this error:
bash: ls /dev/shm: No such file or directory
In the script, ...