English 中文(简体)
A. 最初的多屏幕,其目录载于终端
原标题:initial multiple screen with its own directory on a terminal
  • 时间:2012-05-11 03:33:41
  •  标签:
  • shell

I want open a screen on host1 and change directory to $HOME/bin. host2 and change directory to $HOME/prj.

这里是我的手稿,但骑手可以工作。

#!/bin/bash

start_host() {
    screen ssh $1
    sleep 1
    screen -X chdir $2
}

[ x"$TERM" = x"screen" ] || exec screen -ln -S xxx -c /dev/null $0
sleep 1
screen -X zombie cr
screen -X caption always "%{= wk}%-w%{= BW}%n:%t%{-}%+w%-="

screen /bin/bash
start_host host1 bin
start_host host2 prj
问题回答

我假定,你的问题是开始(在职能<代码>上)而不是按顺序进行筛选。 这意味着指挥<条码> 屏幕扫描仪表1 封顶功能,执行过程可持续到<条码><>>>。

我建议使用<代码>-d-m,开始按脱节方式进行筛选:

start_host() {
  screen -d -m ssh $1
  sleep 1
  screen -X chdir $2
}

这里是我经过尝试和错误后的解决办法。

#!/bin/bash
start_host() { # <host> <dir>
  screen ssh $1
  screen -X eval "stuff  cd $2 " "stuff 15"
  screen -X select 0
}

[ x"$TERM" = x"screen" ] || exec screen -l -c /dev/null $0 $*
screen -X caption always "%{= wk}%-w%{= BW}%n:%t%{-}%+w%-="

start_host host1 bin
start_host host2 prj
read -p "Press enter to quit all windows" a
screen -X quit




相关问题
KornShell- Creating a fixed width text file

I need to create a simple fixed width text file in KornShell (ksh). My current attempt using printf to pad the string isn t working out very well. What s the shortest, cleanest way to create a fixed ...

unix find command

how to use the find command to find files/directories which are not matching the pattern. for eg: find <some options > -name "dontfile.txt" should give me output of all the find whose file ...

encoding of file shell script

How can I check the file encoding in a shell script? I need to know if a file is encoded in utf-8 or iso-8859-1. Thanks

Case insensitive comparison of strings in shell script

The == operator is used to compare two strings in shell script. However, I want to compare two strings ignoring case, how can it be done? Is there any standard command for this?

1. 露台式照像

在Windows XP中,没有一时出现指挥时,是否有办法操作一种灰色文字? 我常常需要把“善待”(工作)与“灰色”同起来,即使我的文字没有产出,......

热门标签