VanDyke Software Forums

VanDyke Software Forums (https://forums.vandyke.com/index.php)
-   Scripting (https://forums.vandyke.com/forumdisplay.php?f=14)
-   -   Keep getting syntax error message from new MENUITEM (https://forums.vandyke.com/showthread.php?t=14500)

BjoernH 04-15-2021 10:46 AM

Keep getting syntax error message from new MENUITEM
 
Good day.

I'm baffled as to why I keep getting a syntax error from this menu item I added to the menu file.

Code:

MENUITEM "&Show IPv4 addresses (all VMs)" , "SEND" , "for  i in {5,6} {8..9}; do echo "";  ssh -q -o "StrictHostKeyChecking no" 192.168.210.$i "uname -n;/usr/sbin/ip a| grep 'inet ' | grep -v host | grep -Eo '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' | grep -v 255$";done\n"
The only way I can get it to launch with the new menu item is when I omit the double-quotes preceding 'uname' and after the '255$'. But that compromises the command after 'uname -n'.

Please advise.

Bjoern

cboyack 04-20-2021 10:14 AM

Hi Bjoernh,

I'm so sorry that this reply is coming so late. I had a response all queued up last week and I must have forgotten to actually post the response. So, here it is:

If you wish to include a special character such as a double quote ("), single quote ('), or backslash (\) in a command string, the octal code for the character should be used instead of the character. Here are the octal codes for those three characters:
  • \042 - double quote
  • \047 - single quote
  • \134 - backslash (escaping it via \\ works as well)
Making the necessary changes to your suggested menu item would make it look like this:

Code:

MENUITEM "&Show IPv4 addresses (all VMs)" , "SEND" , "for  i in {5,6} {8..9}; do echo \042\042;  ssh -q -o \042StrictHostKeyChecking no\042 192.168.210.$i \042uname -n;/usr/sbin/ip a| grep \047inet \047 | grep -v host | grep -Eo \047[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\047 | grep -v 255$\042;done\n"
Does making those changes allow the Menu item to work as desired?


All times are GMT -6. The time now is 03:36 PM.