Date: Tue, 29 Jan 2013 06:39:15 +0000 From: Matthew Seaman <matthew@FreeBSD.org> To: kpneal@pobox.com Cc: Fbsd8 <fbsd8@a1poweruser.com>, FreeBSD questions <questions@freebsd.org> Subject: Re: sh & export Message-ID: <51076E93.7040306@FreeBSD.org> In-Reply-To: <20130129011118.GA71113@neutralgood.org> References: <51070FD6.8070808@a1poweruser.com> <444ni0dewi.fsf@lowell-desk.lan> <51071ABF.1020603@a1poweruser.com> <20130129011118.GA71113@neutralgood.org>
next in thread | previous in thread | raw e-mail | index | archive | help
This is an OpenPGP/MIME signed message (RFC 4880 and 3156) ------enig2MPVAOSTEXMXBGWGVTKIQ Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On 29/01/2013 01:11, kpneal@pobox.com wrote: > On Mon, Jan 28, 2013 at 07:41:35PM -0500, Fbsd8 wrote: >> This is what I am looking at in a sh script >> >> echo export jail_${jailname}_hostname=3D\"${jailname}\" >> puts it into the env >> and this brings it back out >> eval jailname=3D\"\$jail_${jailname}_hostname\" >> >> Question is how can I display from the console command >> line what has been exported? >> >> env issued on the console command line does not show >> any thing named jail. >=20 > Environment variables are only exported to children of the shell that > created or inherited them. When you run a script you normally have your= > command line shell start a child shell which then executes the script. > When the child shell that runs the script finishes the script it ends a= nd > control returns to the parent. The child's environment at this point is= > gone, but the parent couldn't have looked at it anyway. Parents don't > really know what their children are doing. >=20 > So, to answer your question above, "You can't display from the console > what was set in a script." >=20 I'm afraid that's simply not true. ps(1) has a '-e' flag which can show you the environment for any process. However, since printing out the environment will easily overflow the console width that ps(1) uses by default, it's best to combine it with a couple of 'w's. Thus: ps -wwwe ${pid_of_process} Cheers, Matthew --=20 Dr Matthew J Seaman MA, D.Phil. PGP: http://www.infracaninophile.co.uk/pgpkey ------enig2MPVAOSTEXMXBGWGVTKIQ Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.0.16 (Darwin) Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iEYEARECAAYFAlEHbpoACgkQ8Mjk52CukIweqgCfdPDfhokb6MKI8JUXMhqJf7mi xTYAn2qs6tzfFPP8zGENYrnJeB9exJZE =Hs/o -----END PGP SIGNATURE----- ------enig2MPVAOSTEXMXBGWGVTKIQ--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?51076E93.7040306>