1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

shell prompt

Discussion in 'Tomato Firmware' started by phuklok1, Dec 19, 2008.

  1. phuklok1

    phuklok1 Network Guru Member

    Is there something equivalent to the prompt command on Tomato where I would be able to have something like:

    hostname#

    instead of just:

    #

    It would make dealing with multiple routers in a WDS situation a little easier.

    Thanks in advance for any info.
     
  2. ntest7

    ntest7 Network Guru Member

    Something like this in Administration-Script-Init

    echo PS1=\"`nvram get router_name`# \" > /root/.profile

    Note the shell is rather picky about the double quotes, backslashes and reverse-quotes. The line must be exactly as shown above.

    You can use wan_hostname rather than router_name if that's more appropriate for you.

    Seems something like this should be a default setting...
     
  3. fyellin

    fyellin LI Guru Member

    PS1=`nvram get router_name`"# "
     
  4. fyellin

    fyellin LI Guru Member

    Hmm. It looks like ntest7 and I posted at almost the same time, and he beat me.

    Rather than trying to generate a file containing quotes and backquotes in an init file, I've found it simpler and saner to keep a copy of /root/.profile in /jffs. Then at init time, I just do a copy.

    In truth, I have /jffs/files.tar, which contains all the files I want to create or modify tarred up so that they are already in the right directory. Then in my start up script, I do
    Code:
    tar -x -f /jffs/files.tar -C /
    and everything goes to the right place.
     
  5. phuklok1

    phuklok1 Network Guru Member

    Thanks, guys!
     
  6. quinezhu

    quinezhu Addicted to LI Member

    is there any advice to make ssh/telnet prompt on tomato display "current directory #" instead of "#" ?
     
  7. ntest7

    ntest7 Network Guru Member

    This should do that. Read up on /bin/sh if you want any more bells or whistles.

    echo HOST=\"`nvram get router_name`\" > /root/.profile
    echo PS1=\"${HOST}:/root_# \" >> /root/.profile
    echo 'do_cd() {
    cd $@
    PS1="${HOST}:${PWD}_# "
    }
    alias cd=do_cd' >>/root/.profile
     
  8. quinezhu

    quinezhu Addicted to LI Member

    THX, it works :)

    Code:
    # make ssh/telnet prompt current directory
    echo HOST=\"`nvram get router_name`\" > /root/.profile
    echo PS1=\"root@\${HOST}:/root \# \" >> /root/.profile
    echo 'do_cd() {
    cd $@
    PS1="root@${HOST}:${PWD} # "
    }
    alias cd=do_cd' >> /root/.profile
     

Share This Page