Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Behavior when executing a batch file with the ssh command #2201

Open
makat1983 opened this issue Jan 23, 2024 · 2 comments
Open

Behavior when executing a batch file with the ssh command #2201

makat1983 opened this issue Jan 23, 2024 · 2 comments

Comments

@makat1983
Copy link

makat1983 commented Jan 23, 2024

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

@maertendMSFT maertendMSFT transferred this issue from PowerShell/openssh-portable Jan 29, 2024
@mgkuhn
Copy link

mgkuhn commented Feb 4, 2024

A note on terminology: the CLS command CLears the Screen (console character output buffer), not the "history". The term "history", in the context of a command-line shell, usually refers to the list of previously entered commands, which you can retrieve if you e.g. press cursor-up at the prompt.

@mgkuhn
Copy link

mgkuhn commented Feb 4, 2024

Try running ssh -t ... to force the allocation of a pseudo-terminal even when you are not using ssh interactively.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants