boardrider
boardrider

Reputation: 6185

How to run cygwin's startxwin from bashrc?

I use cygwin occasionally, where I start a mintty.exe from Windows 7, and then run the following command to start XWindows and an xterm:

/bin/run.exe /usr/bin/bash.exe -l -c /usr/bin/startxwin.exe &

I tried to automate this xterm creation, by entering the following stanza at the end of my ~/.bashrc:

if [ `ps -ef | grep XWin | wc -l` -lt 1 ] ; then 
    echo "will start Xwin"
    /bin/run.exe /usr/bin/bash.exe -l -c /usr/bin/startxwin.exe 
    sleep 300
fi

However, XWin is not starting, and the following error is printed:

Usage: /usr/bin/grep [OPTION]... PATTERN [FILE]...
Try `/usr/bin/grep --help' for more information.
bash: [: too many arguments

Can you suggest a way to start an xterm instance from Windows?

Notes:


Edit

Based on @EtanReisner and @pjh comments, I changed the startxwin stanza to the following, which is working:

if ( ! pgrep XWin ) > /dev/null ; then 
    echo "will start Xwin"
    /bin/run.exe /usr/bin/bash.exe -l -c /usr/bin/startxwin.exe 
fi

Upvotes: 1

Views: 1012

Answers (1)

boardrider
boardrider

Reputation: 6185

Based on @EtanReisner and @pjh comments, I changed the startxwin stanza to the following, which is working:

if ( ! pgrep XWin ) > /dev/null ; then 
    echo "will start Xwin"
    /bin/run.exe /usr/bin/bash.exe -l -c /usr/bin/startxwin.exe 
fi

Upvotes: 1

Related Questions