I believe you tried to do something similar as in this answer. But the thing is, the sample commands provided there are to be executed from the file on the server.
They cannot be passed as command(s) to execute using -m switch. This switch of PuTTY is to mimic the behavior of Linux command-line SSH client:
ssh user@foo command
This way ssh logs a user on the foo server, runs command there, and just exits. Looks like with -m PuTTY is doing exactly the same thing.
My suggestion
is to prepare a script on the remote server and configure PuTTY in a different way. First of all, you need to create a file with the commands you would like to run after logging in, let's call it .title
cat > ~/.title
Then just type, or copy and paste whatever you need there, press Ctrl+D afterwards. For now let's just test setting the title:
echo -ne "\033]0;PuTTY\007"
You can even try the above directly in terminal. If the window title of PuTTY is not changed, chances are your distribution already set default PROMPT_COMMAND variable. You can confirm that by executing the following commands in terminal
echo $PROMPT_COMMAND
unset PROMPT_COMMAND
echo -ne "\033]0;PuTTY test\007"
The key is to unset current value of PROMPT_COMMAND variable. Then the last command should set the window title to PuTTY test.
My solution
that works for me is to prepare a session in PuTTY, with "Remote command" box in GUI set to:
/bin/bash --rcfile ~/.title
Just remember to provide the name of this session (for example: SessionName) and press "Save" button on the first page of PuTTY settings, near "Saved Sessions" list :)
Then you can start PuTTY and tell it to load this session
putty -load SessionName -l user -pw password
Yes, it's sad, but there is no command-line equivalent of "Remote command" box for a saved session. That's why one has to go over all these hurdles :(
TL;DR version
Assuming that you do all these steps correctly, everything should work fine:
- create
~/.title script on the remote machine
- prepare a session with Remote command that runs Bash which will execute
~/.title
- tell PuTTY to load prepared session upon start, specifying user and password
Pro tip
Instead of specifying passwords in clear text on command line (and possibly in scripts), you should learn to use SSH keys and run 'Pageant' (PuTTY authentication agent) in Windows tray.