Skip to main content

All Questions

Tagged with
1 vote
0 answers
19 views

While Loop Exits After Calling Function [duplicate]

I'm trying to do a db backup script using Bash. When adding a "Resume" feature to the script, I do the following loop calling defined functions to do step by step (depending on the .lock ...
James's user avatar
  • 111
1 vote
1 answer
5k views

ssh to execute remote command under interactive shell

Very similar with Run a command in an interactive shell with ssh after sourcing .bashrc, yet the answer there doesn't work for me. I want to to execute remote command via ssh under the full ...
xpt's user avatar
  • 1,808
-1 votes
2 answers
504 views

How to use pipe with "sudo -ui"?

I have this command cat ~/.ssh/id_dsa.pub | ssh root@[my_server] "cat >> ~/.ssh/authorized_keys" How can I do the same thing but with sudo -iu user1 before the 2nd cat? That is, I ...
Johsua's user avatar
  • 59
0 votes
1 answer
2k views

Executing local script on remote server with local input

I have a python script and input data that the python script takes. I want to execute the python script on remote server without copying python script and data to the remote server. I tried the script:...
simond's user avatar
  • 149
0 votes
1 answer
310 views

using heredoc in case statement for remote ssh host

I have a list of ssh commands to run on remote server, so wrote this snippet. #!/usr/bin/env bash echo '' echo "WOULD YOU LIKE TO PERFORM FILES CLEANUP: " read choice case $choice in yes|...
Sollosa's user avatar
  • 1,983
0 votes
2 answers
2k views

Removing files from remote machine

I remove files with wildcard by rm /home/files/*.csv but when I try run the command on a remote machine via ssh as ssh user@ip 'rm /home/files/*.csv' it tries to delete *.csv file instead, and I get ...
Googlebot's user avatar
  • 1,959
0 votes
1 answer
4k views

Getting rid of "stdin: is not a tty" with remote command execution through ssh

The problem is with a Debian Jessie server. I run a remote command with ssh like the following example. #! /bin/bash ssh root@srv01 << 'STOP_SERVER' touch /tmp/testFile STOP_SERVER This ...
chmike's user avatar
  • 231
0 votes
1 answer
87 views

How can I execute some commands locally while also executing a script remotely via ssh, without interrupting a connection?

I want to execute a script this way: #!/bin/bash # a ssh connection ssh USER@HOST << EOF COMMAND1 COMMAND2 COMMAND3 EOF # here I should execute some commands locally COMMAND4 COMMAND5 # here ...
kosmosu05's user avatar
0 votes
1 answer
128 views

In a bash script, how do I write a command for a remote machine using the remote machine's environment vars?

I'm trying to write a bash script on Ubuntu 18. I have the below script ... #!/bin/bash -l ssh myuser@remote-machine 'mysql -u $DB_USER --password=$DB_PASS $DB_NAME < /tmp/dump.sql' My primary ...
Dave's user avatar
  • 2,738
1 vote
1 answer
577 views

connect to ssh and execute command in spite of changing shells after login

I am trying to connect to a server via ssh and then execute a command. So far so simple. The twist is that on that server, I start zsh from my bash. So in my .bashrc I have the command: exec /bin/...
cmplx96's user avatar
  • 143
1 vote
2 answers
860 views

How to run Bash Script in background [duplicate]

I am remotely connected to a system using ssh and want to run nmap on a system from there. But every 5 minutes, my SSH connection breaks and so the process running on my shell stops. How can I run ...
DeshBhakt's user avatar
  • 145
2 votes
1 answer
3k views

Remove carriage return (\r) from variable in expect script

Setup Ubuntu 16.04 expect Scripts In the simple script bellow the goal is to simply find the oldest .zip file in a directory on a remote machine using ssh. Then use scp to download this file to the ...
DarbyM's user avatar
  • 123
0 votes
1 answer
944 views

Execute a remote bash script locally

I've seen that it's possible to run scripts stored locally on a remote server eg.: run a command: ssh USER@HOST 'COMMAND' run a script ssh [email protected] 'bash -s' < script.sh What about doing ...
lese's user avatar
  • 2,756
1 vote
0 answers
2k views

Remote ssh script execution with EOI or EOSSH adding dots in front of commands

Here the first block was running, second block was not. And the problem was EOI considers spaces as dots, I think. But, it does not consider tab as dot. Making no indentation worked for me. But is ...
Rakib Fiha's user avatar
2 votes
2 answers
2k views

Can you nest remote calls using ssh in a bash script? [duplicate]

I have run into a strange issue that Computer A can see Computer B, Computer B can see Computer C, but Computer A can not see Computer C. I would like to make a bash script that can be run on A that ...
hehe3301's user avatar
  • 145

15 30 50 per page