OpenVZ Forum


Home » Mailing lists » Users » problem run shell script by vzctl exec
problem run shell script by vzctl exec [message #22718] Fri, 02 November 2007 03:42 Go to next message
hhding is currently offline  hhding
Messages: 4
Registered: November 2007
Junior Member
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

what's the problem?

server3:~# vzctl exec 180 cat hi.sh
#!/bin/bash

echo $HOME
server3:~# vzctl exec 180 hi.sh
/
server3:~# vzctl exec 180 echo $HOME
/root

server3:~# aptitude show vzctl
Package: vzctl
State: installed
Automatically installed: yes
Version: 3.0.18-1
Priority: optional
Section: admin
Maintainer: Ola Lundqvist <opal@debian.org <mailto:opal@debian.org>>
Uncompressed Size: 872k
Depends: libc6 (>= 2.3.6-6), iproute, vzquota
Recommends: rsync
Suggests: kernel-patch-openvz
.....

server3:~# uname -a
Linux server3 2.6.18-028stab045 #11 Wed Oct 10 13:28:22 CST 2007 i686
GNU/Linux
server3:~#
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MingW32)

iD8DBQFHKpyoJo9Njjkvy34RAscYAKCATCPihKg3wXmOYRGCbKB/Ha++OwCeM2cL
sAf+xxn1ga2Mynj+rfeCsnQ=
=0ABA
-----END PGP SIGNATURE-----
Re: problem run shell script by vzctl exec [message #22722 is a reply to message #22718] Fri, 02 November 2007 05:50 Go to previous messageGo to next message
Drake Wilson is currently offline  Drake Wilson
Messages: 1
Registered: November 2007
Junior Member
Quoth "hhding.gnu" <hhding.gnu@gmail.com>, on 2007-11-02 11:42:32 +0800:
> what's the problem?
> 
> server3:~# vzctl exec 180 cat hi.sh
> #!/bin/bash
> 
> echo $HOME
> server3:~# vzctl exec 180 hi.sh
> /

Subprocess for bash starts running inside VE 180, begins executing
hi.sh.  It's got a different environment, and expands $HOME into /,
then echoes it to stdout.

> server3:~# vzctl exec 180 echo $HOME
> /root

_Current_ shell expands $HOME into /root.  Subprocess for echo starts
running inside VE 180, with the parameter already expanded.  (vzctl
doesn't even see the "$HOME".)  It is told to echo "/root" to stdout,
so it does.

Does that sound about right?

   ---> Drake Wilson
Re: problem run shell script by vzctl exec [message #22729 is a reply to message #22722] Fri, 02 November 2007 11:34 Go to previous message
dev is currently offline  dev
Messages: 1693
Registered: September 2005
Location: Moscow
Senior Member

yep. the actual command executed in 2nd case is:
server3:~# vzctl exec 180 echo /root

Kirill

On Fri, 2007-11-02 at 00:50 -0500, Drake Wilson wrote:
> Quoth "hhding.gnu" <hhding.gnu@gmail.com>, on 2007-11-02 11:42:32 +0800:
> > what's the problem?
> > 
> > server3:~# vzctl exec 180 cat hi.sh
> > #!/bin/bash
> > 
> > echo $HOME
> > server3:~# vzctl exec 180 hi.sh
> > /
> 
> Subprocess for bash starts running inside VE 180, begins executing
> hi.sh.  It's got a different environment, and expands $HOME into /,
> then echoes it to stdout.
> 
> > server3:~# vzctl exec 180 echo $HOME
> > /root
> 
> _Current_ shell expands $HOME into /root.  Subprocess for echo starts
> running inside VE 180, with the parameter already expanded.  (vzctl
> doesn't even see the "$HOME".)  It is told to echo "/root" to stdout,
> so it does.
> 
> Does that sound about right?
> 
>    ---> Drake Wilson
Previous Topic: Migration error: VPS config file does not exist
Next Topic: Console access with VNC
Goto Forum:
  


Current Time: Wed Nov 06 15:40:38 GMT 2024

Total time taken to generate the page: 0.03237 seconds