stevejenkins / unifi-linux-utils

Helpful Linux / Unix scripts for admins of Ubiquiti (UBNT) UniFi wireless products
https://www.stevejenkins.com/blog/tag/unifi/
MIT License
695 stars 127 forks source link

Syntax Error #20

Closed rea0056 closed 6 years ago

rea0056 commented 6 years ago

I got log _"./uap_reboot.sh: 20: ./uapreboot.sh: Syntax error: "(" unexpected"

I just copy all your script and just change the IP address in the ( ) and I got error _"./uap_reboot.sh: 20: ./uapreboot.sh: Syntax error: "(" unexpected".

I using Ubuntu 16.04.3

Thanks Faiz

stevejenkins commented 6 years ago

Hi, @rea0056. Is this the same issue as #15? If so, the latest version of the script (without quotes in the UAP list) will fix it on Ubuntu and I can close this issue. Thanks!

rea0056 commented 6 years ago

Hi Steve,

I already try without quote but the same message occur _"./uapreboot.sh: Syntax error: "(" unexpected"

Thanks, Faiz

rea0056 commented 6 years ago

1 2

You can refer this picture.

Thanks, Faiz

stevejenkins commented 6 years ago

Very helpful screen caps. Thanks!

Will you please try changing the first line from #!/bin/sh to #!/bin/bash and tell me what happens?

rjt commented 6 years ago

On Wed, Mar 28, 2018 at 10:46 PM Steve Jenkins notifications@github.com wrote:

Very helpful screen caps. Thanks!

Will you please try changing the first line from #!/bin/sh to #!/bin/bash and tell me what happens?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/stevejenkins/unifi-linux-utils/issues/20#issuecomment-377112272, or mute the thread https://github.com/notifications/unsubscribe-auth/AAV_l3wVh-CMsPzJULry9xS8Go9oFoaVks5tjFkmgaJpZM4S-h5U .

For verbosity, you could append an -x, so it looks like:

!/bin/bash -x

rea0056 commented 6 years ago

Hi Steve,

Now the script can be execute by changing #!/bin/sh to #!/bin/bash . But now there was other issue occur.

1

Why permission denied? Is there something I missing?

Thanks, Faiz

stevejenkins commented 6 years ago

Are you able to SSH to those IP addresses manually using the same credentials you put in the script? And BTW, if that's your UniFi password shown in the screencap, you should probably change it. :)

stevejenkins commented 6 years ago

@rea0056, @rjt makes an excellent suggestion. Please temporarily add -x to the first line: #!/bin/bash -x to run Bash in debug mode.

rea0056 commented 6 years ago

Hi Steve,

I able to SSH into the AP manually, but the script can't. Anything that I missing?

1

Thanks Faiz

stevejenkins commented 6 years ago

Please try:

sshpass -p PASSWORD ssh -oStrictHostKeyChecking=no -oUserKnownHostsFile=/dev/null USERNAME@IPADDRESS reboot

with your own PASSWORD, USERNAME, and IPADDRESS of a UAP, then let me know what happens.

rea0056 commented 6 years ago

Hi Steve,

I get the same message "Warning: Permanently added '172.16.3.102' (RSA) to the list of known hosts. Permission denied, please try again."

Thanks Faiz

stevejenkins commented 6 years ago

Ok, so either sshpass or the ssh client are generating that error.

Please try one of the two approaches in the answer here and see if that fixes:

https://askubuntu.com/questions/986179/permission-denied-when-trying-to-run-a-script-that-uses-sshpass

rjt commented 6 years ago

Have not run this script recently and do not have Ubuntu 16 running anyway. Wonder if the permission model of his access points are different in respect to the reboot command. Wonder if he gets the same error when attempting the reboot command manually? Does that user need to actually run sudo reboot ?

Adding -vv to the ssh command line might give some clues as well.

Lastly, when i issue remote ssh commands, i wrap the “command” in quotes, so in this case “reboot”.

On Wed, Mar 28, 2018 at 11:31 PM Steve Jenkins notifications@github.com wrote:

Ok, so either sshpass or the ssh client are generating that error.

Please try one of the two approaches in the answer here and see if that fixes:

https://askubuntu.com/questions/986179/permission-denied-when-trying-to-run-a-script-that-uses-sshpass

— You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub https://github.com/stevejenkins/unifi-linux-utils/issues/20#issuecomment-377118181, or mute the thread https://github.com/notifications/unsubscribe-auth/AAV_l-7w_CWigjouJNqcnQ8rAaOnarv8ks5tjGOIgaJpZM4S-h5U .

rjt commented 6 years ago

Also put your ‘password in single quotes’ or put in a file as mentioned in the article:

It looks the message Permission denied, please try again. is generated by the SSH client. The password should be quoted to escape the special meaning of characters as $, !, etc. (ref https://askubuntu.com/revisions/982438/4 ):

sshpass -p 'footbar' ...

Or you can use a file where the password to be stored (source https://askubuntu.com/a/982438/566421):

sshpass -f "/path/to/passwordfile" ...

On Thu, Mar 29, 2018 at 10:29 AM Rob Townley rob.townley@gmail.com wrote:

Have not run this script recently and do not have Ubuntu 16 running anyway. Wonder if the permission model of his access points are different in respect to the reboot command. Wonder if he gets the same error when attempting the reboot command manually? Does that user need to actually run sudo reboot ?

Adding -vv to the ssh command line might give some clues as well.

Lastly, when i issue remote ssh commands, i wrap the “command” in quotes, so in this case “reboot”.

On Wed, Mar 28, 2018 at 11:31 PM Steve Jenkins notifications@github.com wrote:

Ok, so either sshpass or the ssh client are generating that error.

Please try one of the two approaches in the answer here and see if that fixes:

https://askubuntu.com/questions/986179/permission-denied-when-trying-to-run-a-script-that-uses-sshpass

— You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub https://github.com/stevejenkins/unifi-linux-utils/issues/20#issuecomment-377118181, or mute the thread https://github.com/notifications/unsubscribe-auth/AAV_l-7w_CWigjouJNqcnQ8rAaOnarv8ks5tjGOIgaJpZM4S-h5U .