Path: utzoo!mnetor!tmsoft!torsqnt!news-server.csri.toronto.edu!cs.utexas.edu!helios!archone!byron From: byron@archone.tamu.edu (Byron Rakitzis) Newsgroups: comp.unix.shell Subject: Re: Remote shell question Message-ID: <11702@helios.TAMU.EDU> Date: 1 Feb 91 16:44:08 GMT References: <1991Feb1.125425.14866@cbnews.att.com> <1991Feb1.145242.16915@bradley.bradley.edu> Sender: usenet@helios.TAMU.EDU Distribution: na Organization: College of Architecture, Texas A&M University. Lines: 70 In article <1991Feb1.145242.16915@bradley.bradley.edu> brad@bradley.bradley.edu (Bradley E. Smith) writes: >In <1991Feb1.125425.14866@cbnews.att.com> smk@cbnews.cb.att.com (Stephen M. Kennedy) writes: > >>I want to start up a process in the background on a remote machine using >>remsh (sysV) or rsh (bsd), e.g., > >I had this same problem...what I did was to use a 'C' program below. > >#include >main() >{ > int i; > for (i=0;i<20;i++) { > close(i); > } > i = fork(); > if(i) > exit(0); > execl("/usr/openwin/demo/xterm","bradley", "-ls", "-sb", "-fn","9x15", 0); >} You don't really need to write a C program to close file-descriptors; any reasonable shell like sh or rc can do this for you. I have two shell scripts, "rx" and "xr". I type: rx goofy and rx does an rsh to goofy, invoking "xr" with all the necessary arguments. "xr" then takes care to close the stupid file-descriptors (I've found that going up to 9 is sufficient), puts xterm in the background and exits. Here are "rx" and "xr" in their entirety: ------------- #!/usr/arch/bin/rc if (! ~ $#* 1) { echo usage: rx hostname >[1=2] exit 1 } # an rx from a local window will have DISPLAY set to unix:0.0; this must be changed. switch ($DISPLAY) { case unix:* ~ $#hostname 0 && hostname=`hostname display=`{echo $DISPLAY | sed s/unix:/$hostname:/} case * display=$DISPLAY } rsh $1 -n bin/sh/xr $display $1 >/dev/null & ------------- #!/usr/arch/bin/rc -l DISPLAY=$1 xterm -ls -n $2 -title $2 /dev/null >[2] /dev/null <[3=] <[4=] <[5=] <[6=] <[7=] <[8=] <[9=] & # the redirections are a hack to make sure that the rshd knows it can exit ------------- By the way, this "rx", "xr" setup is due to Paul Haahr, who originally wrote these scripts in sh. Byron. -- Byron Rakitzis byron@archone.tamu.edu