in reply to environment variable
#include <stdlib.h> #include <stdio.h> int main( int argc, char **argv ) { char *arg = *++argv; printf( "%s is %s\n", arg, getenv(arg) ); exit(0); }
which is named env-echo.c, which you should compile with cc -o env-echo env-echo.c. You can then use this script:
And if I run that as ./env-change HOME /tmp the child process prints out HOME is /tmp. What does this code do when you run it on your system? --#! /usr/bin/perl -w use strict; my $var = shift || 'FOO'; my $value = shift || 'bar'; $ENV{$var} = $value; system "./env-echo $var";
|
|---|