-
Notifications
You must be signed in to change notification settings - Fork 240
Description
#!/bin/bash
# Sends a command to the specified instance of IBC, for example to cause it
# to initiate a tidy closedown or restart of TWS or Gateway
# You must supply the command as the first argument when you call this
# script. It is case-insensitive.
# Please read the notes below and make any required changes, then save this
# file before running it.
# You may need to change this line. Set it to the name or IP address of the
# computer that is running IBC. Note that you can use the local loopback
# address (127.0.0.1) if IBC is running on the current machine.
server_address=127.0.0.1
# You may need to change this line. Make sure it's set to the value of the
# CommandServerPort setting in config.ini:
command_server_port=7462
# You shouldn't need to change anything below this line.
# ==============================================================================
if [[ -z "$1" ]]; then
>&2 echo -e "Error: you must supply a valid IBC command as the first argument"
>&2 exit 1
fi
# send the required command to IBC
(echo "$1"; sleep 1; echo "EXIT" ) | /usr/local/bin/telnet "$server_address" $command_server_port
I noticed on macOS the correct key combination for RECONNECTDATA is actually:
Command + Option(Alt) + F
instead of
Ctrl + Alt + F
So that the above script doesn't work on macOS.
What i think needs to be done is to change the code from:
| int modifiers = KeyEvent.CTRL_DOWN_MASK | KeyEvent.ALT_DOWN_MASK; |
and
| int modifiers = KeyEvent.CTRL_DOWN_MASK | KeyEvent.ALT_DOWN_MASK; |
from int modifiers = KeyEvent.CTRL_DOWN_MASK | KeyEvent.ALT_DOWN_MASK;
to int modifiers = KeyEvent.VK_META | KeyEvent.ALT_DOWN_MASK;
As per WickedChive/Matlab-Editor-Plugin#150 (comment) for the key Command
https://stackoverflow.com/a/7375073/1889814
Of course with the check of platform is macOS
https://stackoverflow.com/questions/228477/how-do-i-programmatically-determine-operating-system-in-java
I'm not a Java developer, so the alternatives i'm considering until this is resolved are:
- Run TW in linux virtualized (docker or something else) and use the command to send a telnet command to the linux TW instance, maybe that one receives it correctly.
- Another option would be to implement a library in Objective-C or python to send that key combo to the TW window
- Another option would be to investigate the JAVA library and find the bug and fix it directly in the implementation and send a Pull Request to the library as well - this requires knowledge of ant
- Another option would be to
RESTARTthe TW app each time, this is the simplest solution that i tested and works out of the box, just need to write handling code for waiting until fully reconnected.
Got theRESTARTfrom this undocumented API:IBC/src/ibcalpha/ibc/CommandDispatcher.java
Lines 34 to 57 in 8b5f784
@Override public void run() { String cmd = mChannel.getCommand(); while (cmd != null) { if (cmd.equalsIgnoreCase("EXIT")) { mChannel.writeAck("Goodbye"); break; } else if (cmd.equalsIgnoreCase("STOP")) { handleStopCommand(); } else if (cmd.equalsIgnoreCase("ENABLEAPI")) { handleEnableAPICommand(); } else if (cmd.equalsIgnoreCase("RECONNECTDATA")) { handleReconnectDataCommand(); } else if (cmd.equalsIgnoreCase("RECONNECTACCOUNT")) { handleReconnectAccountCommand(); } else if (cmd.equalsIgnoreCase("RESTART")) { handleRestartCommand(); } else { handleInvalidCommand(cmd); } mChannel.writePrompt(); cmd = mChannel.getCommand(); } mChannel.close(); } - Might be an option to decompile the library and update it, but I'm not familiar on how to do this.
Cheers and thanks for this wonderful library!