Hi Daniel On Sun, Aug 21, 2011 at 08:03:33PM +0200, Daniel Alder wrote: > Yes, please. Forward it upstream
I'll do that. > And, just for clarifying: > I am always aware which host is running. What I want is just calling one > command in a VE and another one later in the host system. Both using a > 100% terminal and both called from the same script. > > I have a 200-lines update script and it took hours to unterstand why > some commands did not work while others did. I was expeting some problem > from my side which I can easially solve, but that was not the case. > > >> command1 >> command2 >> >> is equivivalent to >> >> command1 ; command2 > > That was the funny experience for me: the aren't. According to the > documentation, they are. But in fact, in my examples, they work > differently: > > vzctl enter 201 --exec exit ; read a > (does not work) > > vs. > > vzctl enter 201 --exec exit > read a > (works) This is really really interesting. Maybe this is not a vzctl bug after all. Maybe it is a bash bug... Do you know if the same thing happens if you run dash? I have not checked myself. // Ola > > Daniel > > > > > On 21.08.2011 18:41, Ola Lundqvist wrote: >> Hi Daniel >> >> I'm commenting below. >> >> On Sat, Aug 20, 2011 at 12:16:11AM +0200, Daniel Alder wrote: >>> Sorry ola >>> >>> Even if you try it without the --exec you have to add the "; read a" >>> like this: >>> >>> --- >>> ~# vzctl enter 222; read a >>> entered into CT 222 >>> ct222:~# exit >>> logout >>> exited from CT 222 >>> -bash: read: read error: 0: Resource temporarily unavailable >>> ~# >>> --- >> >> Yes, and that is because read a is executing in the context of outside >> the VE (in the host system), but for some reason the stdin has not been >> gotten back (probably because it was directed to the VE) but the VE command >> is no longer available, because it has exited. I do not know why stdin >> is not directed back. That can be a bug. >> >>> I agree, calling it as two separate commands (in two lines) doesn't have >>> this problem >>> >>> Also, same problem when using in a script (then the commands can be >>> separated: >>> --- >>> ~# cat test.sh >>> #!/bin/sh >>> >>> set -x >>> >>> vzctl enter 222 >>> read a >>> echo $? >>> ~# ./test.sh >>> + vzctl enter 222 >>> entered into CT 222 >>> ct222:/# exit >>> logout >>> exited from CT 222 >>> + read a >>> + echo 1 >>> 1 >>> ~# >>> --- >> >> Yes this will cause the same problem. >> >> command1 >> command2 >> >> is equivivalent to >> >> command1 ; command2 >> >>> according to the documentation, "vzctl enter" is the only one command >>> which provides a stdin which is a terminal. it does not matter if there >>> is a --exec or not. For me, "vzctl enter --exec" is the only one >>> possibility to run an interactive command in a ct. I use it for "vzctl >>> enter --exec exec apt-get dist-upgrade", but I also need a terminal in >>> the host environment because I have to ask some questions to the user. >> >> Ok. I was not aware of this. In any case, see below. >> >> It follows the documentation. >> >> I created a /root/test.sh script in the VE to proove this: >> >> root@test1:/# cat /root/test.sh >> #!/bin/bash >> echo test 1 >> read a >> echo test 2 $a >> read b >> echo test 3 $b >> echo done >> root@test1:/# exit >> logout >> exited from CT 201 >> >> quartz:/home/ola/svn/t# vzctl enter 201 --exec /root/test.sh >> entered into CT 201 >> /root/test.sh >> root@test1:/# /root/test.sh >> test 1 >> aaa >> test 2 aaa >> bbb >> test 3 bbb >> done >> >>> When chrooting, there is no such problem, because it doesn't modify stdin: >>> --- >>> # chroot /var/lib/vz/root/222/ ; read a >>> root@eomer:/# exit >>> exit >>> here i can type >>> # >>> --- >> >> Yes and this is because in a chroot you only have one host. >> >>> the answers to your question: >>> >>> 1) see above: "vzctl enter --exec exec apt-get dist-upgrade". but this >>> does not matter. The problem is that i also use stdin in the host system >>> and as long as the calling shell process is running, I cannot use stdin >>> anymore there >> >> You need to be aware of where you are located. If you are executing >> whithin the VE or outside it. They are essentially different computers. >> You can not have stdin in both places at the same time. >> >> If you want to control it in the way you do, you have to use languages >> like expect (or some perl/python variant of that). >> >>> 2) I don't get this error before. The "read a" in my examples is always >>> separated by a unquoted ";" which makes it running in the host system >> >> Yes. Is that a serious problem? >> >>> 3) I really think it is a serious problem and I cannot understand what >>> happens. I wonder that a ressource can be left open as long as a parent >>> process (sh) of a child process (vzctl) is running, but the child >>> process itself is already terminated. >> >> I start to see what you as a problem. >> >>> Another idea would be to include a 'vzctl exec' parameter which provides >>> a terminal-like stdin. This would provide a nicer way for scripting, but >>> I does not solve this problem itself. It would even have the same >>> problem if it uses the same code. >> >> Alternatively you can use some language like expect to control this >> easier. >> >> Do you want me to forward this bug upstream? >> >> // Ola >> >>> >>> Cheers >>> Daniel >>> >>> >>> On 19.08.2011 07:10, Ola Lundqvist wrote: >>>> Hi Daniel >>>> >>>> What I can reproduce is that you get a >>>> "Resource temporarily unavailable" message for this line >>>> >>>> quartz:/home/ola/svn/t# vzctl enter 201 --exec exit ; read a >>>> entered into CT 201 >>>> exit >>>> root@test1:/# exit >>>> logout >>>> exited from CT 201 >>>> bash: read: read error: 0: Resource temporarily unavailable >>>> >>>> But not when you do it without --exec. >>>> >>>> quartz:/home/ola/svn/t# vzctl enter 201 >>>> entered into CT 201 >>>> root@test1:/# exit >>>> logout >>>> exited from CT 201 >>>> quartz:/home/ola/svn/t# read a >>>> ^C >>>> No problem this time. >>>> >>>> And not with: >>>> quartz:/home/ola/svn/t# vzctl enter 201 >>>> entered into CT 201 >>>> root@test1:/# read a >>>> ^C >>>> root@test1:/# exit >>>> logout >>>> exited from CT 201 >>>> And no problem here. >>>> >>>> When you do a enter and --exec I do not think you actually have >>>> any stdin available. I may be wrong here but enter is special >>>> in that sense. I think the same applies when you do chroot. >>>> >>>> If you want I can forward this bug report to upstream but first >>>> I need to understand a bit more about your problem. Is it >>>> one of the following? >>>> >>>> 1) You do not have a stdin in commands that you use with --exec ? >>>> 2) That you get resource unavailable also after you have exited >>>> from the CT? >>>> 3) Something else? >>>> >>>> Best regards, >>>> >>>> // Ola >>>> >>>> >>>> On Wed, Aug 17, 2011 at 12:40:31AM +0200, Daniel Alder wrote: >>>>> Package: vzctl >>>>> Architecture: i386 >>>>> Version: 3.0.24-12 >>>>> >>>>> Try the following command lines in bash: >>>>> >>>>> ---- >>>>> $ set -x >>>>> $ vzctl enter 222 --exec exit ; read a >>>>> + vzctl enter 222 --exec exit >>>>> entered into CT 222 >>>>> exit >>>>> root@durin:/# exit >>>>> logout >>>>> exited from CT 222 >>>>> + read a >>>>> -bash: read: read error: 0: Resource temporarily unavailable >>>>> $ >>>>> $ read a >>>>> + read a >>>>> here i can type >>>>> $ >>>>> ---- >>>>> >>>>> The command which follows after the vzctl call does not work if it uses >>>>> stdin. A command like apt-get will even switch to non-interactive mode. >>>>> >>>>> The strange thing is, that the next command typed at the command line >>>>> works without problems. >>>>> >>>>> When using the same commands in a script file, stdin is blocked until >>>>> the end of script execution, which makes it impossible for me to do some >>>>> batch jobs. >>>>> >>>>> >>>>> "vzctl enter 222 --exec exit" was only an example. you can also try >>>>> "vzctl enter 222" and type exit manually >>>>> >>>>> >>>>> When using the above commands using dash 'read' outputs the following >>>>> message: "turning off NDELAY mode" >>>>> >>>>> >>>>> >>>> >>> >>> >> > > -- --- Inguza Technology AB --- MSc in Information Technology ---- / [email protected] Annebergsslingan 37 \ | [email protected] 654 65 KARLSTAD | | http://inguza.com/ Mobile: +46 (0)70-332 1551 | \ gpg/f.p.: 7090 A92B 18FE 7994 0C36 4FE4 18A1 B1CF 0FE5 3DD9 / --------------------------------------------------------------- -- To UNSUBSCRIBE, email to [email protected] with a subject of "unsubscribe". Trouble? Contact [email protected]

