HillSonMX
HillSonMX

Reputation: 1

How to redirect command output to different remoting session terminal into Windows Powershell (Terminal)

Normally I do it into an ssh session from Windows 10 Pro to my android/termux device ( that I am sure could be any linux Distro ) in the next way.

ssh to my devive (android/termux) like traditional ssh remote connection, one into my device I run ps -u <username> command and check all available TTY sessions

  PID TTY          TIME CMD
 8814 ?        00:00:00 sshd
22938 pts/0    00:00:00 /data/data/com.termux/files/usr/bin/zsh
25088 ?        00:00:00 /data/data/com.termux/files/usr/libexec/sshd-session
25169 ?        00:00:00 /data/data/com.termux/files/usr/libexec/sshd-session
25175 pts/1    00:00:00 /data/data/com.termux/files/usr/bin/zsh
29302 pts/1    00:00:00 ps

after that a run tty command just to check what is my local (android/termux (linux)) pts terminal, /dev/pts/1 in my case. so that mean the another one that is pts/0 is the remote one.

I run echo "Hello word??" 1>/dev/pts/0 and the output display perfecly just in the remote device terminal.

In Windows Terminal to Windows Terminal devices, that is what a need, fisrt I do PSRemoting Session.

$XSession = New-PSSession -ComputerName <device name> -Authentication Basic -Credential (Get-Credential)

Because I have Windows Subsystem for Linux (WSL) in local device, I do tty and get /dev/cons0 sadly not the same in my remote device so I can not know what terminal are runing there, then what I run is

Invoke-Command -Session $XSession -ScriptBlock { echo "Hello word!!" 1>1 } -Verbose

without result, the trick I am sure is in REDIRECTION but I have tried a couple of them, like 1>&1 1>/dev/cons1, unsuccessfully, here is where I will need your help.

Upvotes: 0

Views: 27

Answers (0)

Related Questions