PowerShell / PowerShell/Win32-OpenSSH

Behavior when executing a batch file with the ssh command

Open
#2,201 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Investigate
Dominant language
No language data
Stars
8.3k
Forks
819
PR merge metrics
No merged PRs in 30d

Description

Summary of the new feature / enhancement

Run the batch file with the ssh command in the following way.
The batch file contains the cls command, but does not erase the history.
Running the same batch file while connected to ssh, cls works.

  1. Create a batch file on the server that does the following

echo test

cls

  1. Execute the following command to run the batch file with the ssh command

ssh user@server "chcp 65001 && C:\path\to\xxx.bat"

3.The result of the batch file execution is returned. cls does not erase the history.

PS C:\Users\makat> ssh user@server "chcp 65001 && C:\path\to\xxx.bat"
administrator@home's password:
Active code page: 65001

administrator@HOME C:\Users\Administrator>echo test
test

administrator@HOME C:\Users\Administrator>cls

PS C:\Users\makat>

I assume that the reason the history does not disappear with the former method is that the results of the batch file executed on the server are returned to the local console of the client.
I assume that the history disappears with the latter method because you are establishing an SSH connection and interacting directly with the server shell, so the effect of cls is reflected in the client's console.

Is the former behavior by design? If not, please consider whether it can be changed so that it is the latter behavior.

Proposed technical implementation details (optional)

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the two command forms from the issue: running the Windows batch file through ssh user@server "chcp 65001 && C:\path\to\xxx.bat" and using an interactive SSH session. Compare how cls output is handled in each case. Done means determining whether the non-clearing behavior is intentional and documenting or implementing the expected console behavior.

Written by the indexing model from the issue text.

Assessment

Domain
cli, operating-systems
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.