How to access local variables in remote server using ssh [closed] - linux

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 years ago.
Improve this question
I am trying to access my local variable in remote server. Which command should I use.
Ex.
cmd:
SERVER 1
VAR=2
ssh unix-user#remote-server-name "bash abc.sh"
REMOTE SERVER:
cat abc.sh
echo $VAR
output should get 2.

Set the variable directly on the remote side:
ssh unix-user#remote-server-name "export VAR=2; bash abc.sh"

Related

Path to Files on server [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I want to use git for my sites. So I understand that I have to use SSH and initialize git in the folder. But I can't find those files and want to know what is the path for those files?
something I found, If you have PHP then you can use this to get absolute path
<?php
$path = getcwd();
echo "This Is Your Absolute Path: ";
echo $path;
?>
example :- /home/user/public_html/test/test.php.
refrence :- Check this

Tie a bash script to the ssh command [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
Is there any way to edit the ssh command in such way that 'ssh hostname' runs a bash script first before its standard function
Edit: Note that the ssh command's name stays the same, without adding anything to it.
Use shell alias. In your case:
alias ssh="echo 'hi'; ssh "
From now on, when you type ssh in the terminal, the shell will expand the alias.
In a shell script, you would need shopt -s expand_aliases for it to work.
You can use ProxyCommand.
Add to your ~/.ssh/config:
Host hostname
ProxyCommand /path/to/bash-script

Keeping Alive a ssh session with a script bash/expect [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
Hello People i'm trying to do an script bash using a expect part to enter a server and keep alive the session, my script is as follow:
#!/bin/bash
/usr/bin/expect << eof
spawn ssh user#server
set prompt ":|#|\\\$"
expect "password"
interact
eof
I can enter to the server but the session dies after a second and return to my local computer,
Can any one help me please?
The problem is because of HEREDOC usage. Instead you could quote the whole code as
#!/bin/bash
/usr/bin/expect -c '
spawn ssh dinesh#myhost
set prompt ":|#|\\\$"
expect "password"
interact
'

BASH script to check if the linux server is "up" [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I want to create a BASH script to check if the Linux Web Server is "up" and run it automatically once every five minutes from the "internal" Linux Server and send an e-mail from from the script if a failure is detected.
Can someone please help me to make the script? Since i'm new to scripting.
If you want verify if a Web server is up and running, make a script to verify if exist a PID or process named with "apache" - Considering that you have web server Apache - this will show you not only if the machine is up and running but also if the webservice is working.
For a more professional tool, you can use Nagios.
Something like:
while sleep 60; do
if ! wget -o /dev/null www.example.com/; then
sendmail admin#example.com <<EOF
Subject: www.example.com is down
www.example.com is down, please do something.
.
EOF
fi
done

transfer hundreds of files using ssh from remote http host [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
I want to download hundreds of files from some website to my own server using ssh, the remote files are in series: 0001.jpg : 0900.jpg
how to do this ?
thanks
If you only have HTTP access then I don't understand why you say you want to use SSH...
Here's how to do it over HTTP:
curl -f -O http:www.example.com/folder/image[0001-0900].jpg
scp accepts wildcards.
ie:
scp user#host:/path/* ./path/to/files/locally/
you can use scp with your username and password on remote server.

Resources