1

When I am doing automatic PuTTY login from Windows bat file, after login command prompt is showing only dollar sign in UNIX terminal. But when I am doing manual login in PuTTY, after login, it is showing full directory name in UNIX terminal.

I am doing automatic PuTTY login this way:

putty.exe -ssh [email protected] -pw mypasswordforsomewherecom -m cmd.txt -t

In cmd.exe file there are some UNIX commands to run in remote computer:

mkdir test
/n
sh   

What I have observed that .profile of user is not executing when I am doing automatic PuTTY login. But .profile is executed when doing manual PuTTY login to the same server.

2 Answers 2

1

Your script is running the 'sh' shell, and the simple $ prompt is completely normal for sh.

If your usual shell prompt includes more information, then you were probably using bash or zsh. (But it could also be 'tcsh' or 'fish' or something else.)

  • Try changing your script's last command to bash.

  • Try changing your script's last command to run $SHELL. (Literally just $SHELL.)

  • Try adding the -l option to the command, to force the shell to run in "login mode".

4
  • when i use echo $SHELL, to get the value ,it prints /usr/bin/sh
    – JiT SaHa
    May 19, 2021 at 8:17
  • when i am using -l option ,error message is showing telling that -l requires argument
    – JiT SaHa
    May 19, 2021 at 17:06
  • Add -l to bash commandline, not plink commandline. May 20, 2021 at 9:51
  • problem is that if i use sh -l ,,,the putty screen is closed immediately, But if i use only sh putty screen is not closed immediately.But in the login shell it is showing only dollar.My requirement is that putty screen should not closed immediately and the login shell should display full path ,not the dollar sign
    – JiT SaHa
    May 20, 2021 at 18:02
0

You just need to change your default shell. Typically (as when I was dealing with this issue), you're probably looking for Bash. As the user (whom the shell is only display '$'), run:

sudo chsh <username> -s /bin/bash

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .