Remotely refresh the jsp page with wget command. (No such file or directory)

StackOverflow https://stackoverflow.com/questions/21397937

  •  03-10-2022
  •  | 
  •  

質問

My project's war(same) is deployed on different server and i want to refresh the cache from some jsp page...

Basically i want... remotely hit some url from the wget command in .sh file. (my.sh)

I have tried...

If i execute

wget http://localhost:8080/someDirectory/refreshSomePage.jsp

on individual server... it will hit the server and refresh the page....

In .sh file I did this:

#!/bin/bash

declare -a _servers=('192.168.1.1' '192.168.1.2' '192.168.1.3' '192.168.1.4')

for ((i=0;i<${#_servers[@]};i++));
do
        echo "-------- Server: ${_servers[i]} ---------"
        ssh myUser@${_servers[i]} < wget http://localhost:8080/someDirectory/refreshSomePage.jsp
        echo "-------- Complete ---------"
done

but it will give following result:

-------- Server: 192.168.1.1 ---------
my.sh: line 11: wget http://localhost:8080/someDirectory/refreshSomePage.jsp: No such file or directory
-------- Complete ---------
-------- Server: 192.168.1.2 ---------
my.sh: line 11: wget http://localhost:8080/someDirectory/refreshSomePage.jsp: No such file or directory
-------- Complete ---------
-------- Server: 192.168.1.3 ---------
my.sh: line 11: wget http://localhost:8080/someDirectory/refreshSomePage.jsp: No such file or directory
-------- Complete ---------
-------- Server: 192.168.1.4 ---------
my.sh: line 11: wget http://localhost:8080/someDirectory/refreshSomePage.jsp: No such file or directory
-------- Complete ---------

How to solve this?

役に立ちましたか?

解決

I guess your misstake is that use the pipe symbol which is not necessary. Also you download from localhost which is the localhost of each server itself.

So try this:

#!/bin/bash

declare -a _servers=('192.168.1.1' '192.168.1.2' '192.168.1.3' '192.168.1.4')
ORIGIN = "192.168.1.254"

for ((i=0;i<${#_servers[@]};i++));
do
    echo "-------- Server: ${_servers[i]} ---------"
    ssh myUser@${_servers[i]} wget http://${ORIGIN}:8080/someDirectory/refreshSomePage.jsp
    echo "-------- Complete ---------"
done

I just hope that you use a ssh key based authorization to avoid any future inputs.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top