|
View:
New views
4 Messages
—
Rating Filter:
Alert me
|
|
|
Problems scripting screenI'm having a problem that I hope someone can assist with.
I am running a script to start a number of screen sessions for i in `cat serverlist do screen -d -m -S $i ssh $i done We have the systems setup so we can ssh without a passkey, so I get a number of screens. Now, say I want to stuff a command.. screen -S machine1 -X stuff "who^J" This works. However if I put it in for a for look for i in `cat serverlist` do screen -S $i -X stuff "who^J" done It doesn't. Nothing gets sent to the screen sessions at all. Anyone have a solution for this? Thanks, Nigel |
|
|
Re: Problems scripting screenNelgin wrote:
> Now, say I want to stuff a command.. > > screen -S machine1 -X stuff "who^J" > > This works. However if I put it in for a for look > > for i in `cat serverlist` > do > screen -S $i -X stuff "who^J" > done The most obvious explanation is that your for-loop isn't doing what you think it's doing. Screen of course can't possibly know whether or not it's being invoked as part of a for-loop, or a direct command: given the same command arguments and the same environment (and sessions state), it will behave the same way every time. Knowing this, you should investigate how your for loop is behaving with respect to how you expect it to behave. Perhaps the very act of running from a script versus typing directly on a console introduces an environmental change (fairly unlikely, but worth confriming). Perhaps the values in "serverlist" aren't what you expect them to be, or the file's not in the current working directory. Try placing an "echo" line, or invoke the script using sh's -x option for explanations of how the shell is evaluating your code. -- HTH, Micah J. Cowan Programmer, musician, typesetting enthusiast, gamer. Maintainer of GNU Wget and GNU Teseq http://micah.cowan.name/ _______________________________________________ screen-users mailing list screen-users@... http://lists.gnu.org/mailman/listinfo/screen-users |
|
|
Re: Problems scripting screenOn Fri-2009/06/26-18:34 Nelgin wrote:
> screen -S machine1 -X stuff "who^J" > > This works. However if I put it in for a for look > > for i in `cat serverlist` > do > screen -S $i -X stuff "who^J" > done > > It doesn't. Nothing gets sent to the screen sessions at all. I'd write: >>screen -S "$i" -X stuff "who^J"<<, ie. quote the variable as well. But for testing, try >>echo screen -S "$i" -X stuff "who^J"<<. This will show the command as the shell sees it. Is the "^J" a literal newline or the two characters "^" and "J" in both cases? clemens, being late, he knows. _______________________________________________ screen-users mailing list screen-users@... http://lists.gnu.org/mailman/listinfo/screen-users |
|
|
Re: Problems scripting screenOn Saturday 03 October 2009 11:34:32 clemens fischer wrote:
> Is the "^J" a literal newline or the two characters > "^" and "J" in both cases? Screen itself interprets the two characters "^" and "J" as a newline. So type the command with the two characters, and when the "stuff" command is executed those characters are replaced by a newline. Gerald Young _______________________________________________ screen-users mailing list screen-users@... http://lists.gnu.org/mailman/listinfo/screen-users |
| Free embeddable forum powered by Nabble | Forum Help |