dnickel has asked for the wisdom of the Perl Monks concerning the following question:

I am running this simple system call in one of my scripts on a FREEBSD box:

system ("setenv RSYNC_PASSWORD $passwd");

but I recieve the following error

Can't exec "setenv": No such file or directory at temp.pl line 4.

Does anybody have any suggestions ...Thanxks David

Replies are listed 'Best First'.
Re: setenv system call
by busunsl (Vicar) on Feb 05, 2002 at 15:39 UTC
    derby pointed out the problems with your code.

    Here is a pure perl solution, that should work:

    $ENV{RSYNC_PASSWORD} = $passwd;
Re: setenv system call
by derby (Abbot) on Feb 05, 2002 at 15:31 UTC
    dnickel,

    Well there are a couple issues with this. First off, setenv is not a program per se but a shell built-in. Second off, setenv is not a sh built-in, which is the shell used when using system. And third, this wouldn't work even if it were a extant program because when you do a system, it forks another process and any changes to that child processes enviroment will not be "see-able" by the parent process.

    Some rsync's have a --password-file option, you could use that instead.

    -derby

    Updated: left off a verb!

Re: setenv system call
by particle (Vicar) on Feb 05, 2002 at 15:24 UTC
    try setting the full path to setenv.

    Update: see derby and busunsl's replies below for good answers. what do i know, i'm running on win98! some clients...

    ~Particle

      I can not seem to find the full path to setenv... I have
      tried everything. When I do a whereis I get nothing!!!
      David
Re: setenv system call
by rdfield (Priest) on Feb 05, 2002 at 15:36 UTC
    Does system("setenv","RSYNC_PASSWORD $passwd"); work any better? (or perhaps /path/to/setenv is required).

    rdfield

    update Someone --'d this node. I'll gladly withdraw this advice it it's wrong, just let me know.