Is it possible to run the Swift REPL within an SSH session? - swift

Has anyone tried running the Swift REPL within a local or remote SSH session?
xcrun swift runs great within a local Terminal session, but fails for me with
error: failed to launch REPL process: process exited with status -1) (lost connection)
in an SSH session (either remotely via iPad or when ssh'd into localhost directly on my desktop Mac).

The problem is that OSX is trying to prompt you graphically for your password, but it can't do that over SSH. To get around this, you need to enable developer mode on the machine. You probably did it (unknowingly) by debugging a project in Xcode, which prompts you to enable developer mode.
You can also run this from the command line (including over SSH):
sudo /usr/sbin/DevToolsSecurity --enable

Assuming swift is in your shell path:
$ ssh -t localhost swift
Password:
Welcome to Swift! Type :help for assistance.
1> 1
$R1: Int = 1
2> var foo = 10
foo: Int = 10
3> foo + 1
$R2: Int = 11
and remotely:
$ ssh -t gozoner#10.0.1.6 swift
Password:
Welcome to Swift! Type :help for assistance.
1> 1
$R1: Int = 1
2> 10
$R2: Int = 10
3>

Related

CISCO IOS-XR, Python3.7, Not able to run commands like 'ls' and 'df' on Cisco router

Cisco ios-xr router using CLI:
RP/0/RP0#show version
Thu Nov 25 07:53:59.103 UTC
Cisco IOS XR Software, Version 6.5.32.11I
Copyright (c) 2013-2020 by Cisco Systems, Inc.
RP/0/RP0#run
Thu Nov 25 07:54:05.231 UTC
[xr-vm_node0_RP0_CPU0:~]$df
Filesystem 1K-blocks Used Available Use% Mounted on
rootfs 3966080 1332040 2412860 36% /
76892 11848320 43% /mnt/ecu/vdd
[xr-vm_node0_RP0_CPU0:~]$
Using python:
I am able to run show commands using Connecthandler .send.command:
from netmiko import ConnectHandler
import subprocess
Network_Device = {"host": "10.111.22.333", "username": "USER123", "password": "Pass123", "device_type": "cisco_xr",}
Connect = ConnectHandler(**Network_Device)
Connect.enable()
version1 = "show version"
print(Connect.send_command(version1))
But not able to run 'df' or 'ls' commands, as not able to reach bash prompt i reach by running 'run' command on router.
I tried:
disk1files = subprocess.run("df", stdout=subprocess.PIPE)
print(disk1files.stdout.decode())
But seems its wrong. Please suggest the right library or code I can use here.
This is my first question here, so bear some silly questions or mistakes done in code
if on DF you are referring to "Don't fragment" then it is posible to send it like
Connect.send_command("ping 192.168.10.10 df-bit size 1600")
where 1600 represents MTU, and for ls commands is link command,
Connect.send_command("ls-active")
Connect.send_command("ls-active-enabled")
but if you are referring to df and ls in linux (disk free and list files..) then you can use os module for sending commands:
import os
os.system("ls -l")
or use call from subprocess module:
from subprocess import call
call(["ls", "-l"])
If you need to acccess cisco bash:
switch# configure terminal
switch(config)# feature bash-shell
switch# run?
run Execute/run program
run-script Run shell scripts
switch# run bash?
bash Linux-bash
switch# run bash
bash-4.2$ whoami
admin
bash-4.2$ pwd
/bootflash/home/admin
bash-4.2$

eclipse CDT esp-idf build but don't flash

Windows10 eclipse esp-idf latest version 2021-03
With the command line idf.py I can build and flash the esp-idf\examples\get-started\blink programme which run on a ESP32.
In eclipse, the buils works but the run command display in console
Usage: C:\Users\peter\esp-idf\tools\idf.py [OPTIONS] COMMAND1 [ARGS]...
[COMMAND2 [ARGS]...]...
ESP-IDF CLI build management tool. For commands that are not known to
idf.py an attempt to execute it as a build system target will be made.
.... bla bla ...
Can anybody tells me what is wrong ?
Regards
There is a bug in the eclipse/esp-idf launch bar.
The ESP target for esp32 is defined with a Serial Port COM3.
But that info is not used.
If one redefine a new ESP Target with the same serial port under a different name, then the run command will work!
See hereafter for the people interested in the details
cmd.exe /C "cd /D C:\Users\peter\esp-idf\components\esptool_py && C:\Users\peter.espressif\tools\cmake\3.16.4\bin\cmake.exe -D IDF_PATH="C:/Users/peter/esp-idf" -D ESPTOOLPY="C:\Users\peter.espressif\python_env\idf4.2_py3.8_env\Scripts\python.exe C:/Users/peter/esp-idf/components/esptool_py/esptool/esptool.py --chip esp32" -D ESPTOOL_ARGS="--before=default_reset --after=hard_reset write_flash #flash_args" -D WORKING_DIRECTORY="C:/Users/peter/eclipse-workspace/blink/build" -P C:/Users/peter/esp-idf/components/esptool_py/run_esptool.cmake"
esptool.py --chip esp32 -p COM3 -b 460800 --before=default_reset --after=hard_reset write_flash --flash_mode dio --flash_freq 40m --flash_size 2MB 0x8000 partition_table/partition-table.bin 0x1000 bootloader/bootloader.bin 0x10000 blink.bin
esptool.py v3.0

Why windows commands are not working in vscode-insiders' terminal (error: <3>init: (632) ERROR: UtilConnectUnix:466: connect failed 111)

VSCode Version: 1.53.0-insider (x64)
OS Version: Microsoft Windows [Version 10.0.21292.1010]
WSL version: WSL 2
distribution: Ubuntu-20.04
Steps to Reproduce:
(in wsl.exe)Type code-insiders ~ && exit
Press ctrl+j in the VSCode window
Type explorer.exe .
Result:
It shows me this error:
<3>init: (632) ERROR: UtilConnectUnix:466: connect failed 111
Question:
How can I fix it and why it is happening ?
Extensions on WSL:
ms-vscode.cpptools
eamodio.gitlens
ms-toolsai.jupyter
ms-python.vscode-pylance
ms-python.python
I think I had a similar issue here, you have to check the environment variables of you WSL2 session.
WSL_INTEROP=/run/WSL/197_interop
if this points to a not existing socket the connection fails.
cheers
Marco

VS code keeps reconnecting to remote ssh

Problem: VS code keeps disconnecting / reconnecting ssh with remote machine.
After entering password it immediately comes back with password prompt again.
The logs suggest that vs code server fails.
Are there any vs code server logs I can review on the remote machine?
Details: VS code ver 1.4.5 / Windows 10;
Remote: Macbook Air (High Sierra)
Logs are below:
[09:49:41.088] > Password:
[09:49:41.088] Showing password prompt
[09:49:45.455] Got password response
[09:49:45.456] "install" wrote data to terminal: "********"
[09:49:45.889] > 028771948a23: running
[09:49:45.922] > Acquiring lock on /Users/user/.vscode-server/bin/5763d909d5f12fe19f215cbfdd
> 29a91c0fa9208a/vscode-remote-lock.user.5763d909d5f12fe19f215cbfdd29a91c0fa9
> 208a
> \ln /Users/user/.vscode-server/bin/5763d909d5f12fe19f215cbfdd29a91c0fa9208a
> /vscode-remote-lock.user.5763d909d5f12fe19f215cbfdd29a91c0fa9208a.target /U
> sers/user/.vscode-server/bin/5763d909d5f12fe19f215cbfdd29a91c0fa9208a/vscod
> e-remote-lock.user.5763d909d5f12fe19f215cbfdd29a91c0fa9208a
>
[09:49:45.943] > Found existing installation at /Users/user/.vscode-server/bin/5763d909d5f12
> fe19f215cbfdd29a91c0fa9208a...
>
[09:49:46.017] > Found running server...
[09:49:46.050] > Checking server status on port 58236 with curl
>
[09:49:46.083] > 000
> 028771948a23##28##
>
[09:49:46.083] Received install output: 028771948a23##28##
[09:49:46.083] Server status check failed - waiting and retrying
[09:49:46.364] "install" terminal command done
[09:49:46.364] Install terminal quit with output:
[09:49:47.091] Running script with connection command: "C:\Program Files\Git\usr\bin\ssh.exe" -T -D
55978 10.0.0.134 bash
[09:49:47.092] Terminal shell path: C:\Windows\System32\cmd.exe
[09:49:47.275] >
[09:49:47.281] Got some output, clearing connection timeout
[09:49:50.747] > Password:
[09:49:50.748] Showing password prompt

INSTRUMENTATION_FAILED when run android automation test from sh

I'm doing automation test for an android app. My test code is ready and good to run from android studio and manual command from android device. But when I change the command to sh, it failed with INSTRUMENTATION_FAILED. Anyone can help me how to fix it? I just don't understand, why it's working when directly run from terminal, but failed when run from sh.
Manual input comment, which is working:
am instrument -w -r -e debug false -e class com.amap.auto.androidautomation.testcases.basemap.SmokeTest com.amap.auto.androidautomation.test/android.support.test.runner.AndroidJUnitRunner
Result:
INSTRUMENTATION_STATUS: numtests=9
INSTRUMENTATION_STATUS: stream=
com.amap.auto.androidautomation.testcases.basemap.SmokeTest:
INSTRUMENTATION_STATUS: id=AndroidJUnitRunner
INSTRUMENTATION_STATUS: test=smoke01
INSTRUMENTATION_STATUS: class=com.amap.auto.androidautomation.testcases.
Run from sh:(the command is the same as manual, just put it in a sh file)
sh r.sh
Result:
INSTRUMENTATION_STATUS: id=ActivityManagerService
INSTRUMENTATION_STATUS: Error=Unable to find instrumentation info for: Component
Info{com.amap.auto.androidautomation.test/android.support.test.runner.AndroidJUn
}tRunner
INSTRUMENTATION_STATUS_CODE: -1
android.util.AndroidException: INSTRUMENTATION_FAILED: com.amap.auto.androidauto
mation.test/android.support.test.runner.AndroidJUnitRunner
at com.android.commands.am.Am.runInstrument(Am.java:1093)
at com.android.commands.am.Am.onRun(Am.java:371)
at com.android.internal.os.BaseCommand.run(BaseCommand.java:47)
at com.android.commands.am.Am.main(Am.java:100)
at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:251)
: not foundnload/r.sh[2]: exit