> > system("cat cab.??|tar vxz -C ${DESTDIR}"); > > Here your "${DESTDIR}" is being interpolated to use perl's DESTDIR variable instead of the shell's. Is this what you intended (is it even set, are you running with strict and warnings?) Other than that it should be working I believe. Are you getting an error result? You should check for one by adding an 'or die ("Couldn't tar files: $!")' or some such to the system call, or check the return value ($?).
.... yeh I know, I didnt want to write an ungly system call, this is what I am really using..... system("cat cab.??|tar vxz -C \$\{DESTDIR\}"); following up on ...> Remember your script runs in Perl not in the shell, you run the perl interpreter in the shell, and I believe Perl uses whatever shell is default on the system for how to run its "system" calls, aka most likely /bin/sh (which could be pointed to tcsh, but may not)<... I will probebly go with expanding a variable set with in my script. By the way is there a way to find which shell is default, I am developing on FreeBSD and sh is the default shell, but I will be runing these scripts as root, and tcsh is the default root shell, this would be of segnificance. >To maintain the shell's environment if this can't be handled in Perl, you may be able to string commands together in one >command to system separated by ;'s like on the command line, but this I am not sure about. will look into that. Thanx, Mark ----- Original Message ----- From: <[EMAIL PROTECTED]> To: "Mark Goland" <[EMAIL PROTECTED]>; "perl" <[EMAIL PROTECTED]> Sent: Wednesday, January 15, 2003 2:04 PM Subject: RE: waitpid > > ------------------------------------------------ > On Wed, 15 Jan 2003 12:55:39 -0500, Mark Goland <[EMAIL PROTECTED]> wrote: > > > Hello Perl lovers, > > > > I am developing a script which runs in TCSH 6.x shell. I have two questions > > > > Remember your script runs in Perl not in the shell, you run the perl interpreter in the shell, and I believe Perl uses whatever shell is default on the system for how to run its "system" calls, aka most likely /bin/sh (which could be pointed to tcsh, but may not). > > > 1. I need to be able to set an global enviernment variable. The shell has a > > build in command setenv which would enable me to do what I need. This is > > what I try, > > > > system("setenv DESTDIR /mnt"); > > > > This is most likely succeeding (assuming the shell accepts it all) but I would imagine the shell is started, the command is run, and the shell is closed. So your subsequent call to the shell will be invoked in a new instance of the environment, without what you set. But it appears there is no reason to use this, at least not in this code segment, see below. > > > > ...but this fails , by hand in works great. Source has the same problme. Any > > ideas ??? > > > > 2. I need to run a few external commands sequantialy. Run one wait on it to > > compleate run the others.... a sample command would be > > > > system("cat cab.??|tar vxz -C ${DESTDIR}"); > > Here your "${DESTDIR}" is being interpolated to use perl's DESTDIR variable instead of the shell's. Is this what you intended (is it even set, are you running with strict and warnings?) Other than that it should be working I believe. Are you getting an error result? You should check for one by adding an 'or die ("Couldn't tar files: $!")' or some such to the system call, or check the return value ($?). > > > > > In C I would usually fork and waitpid on child, I was wondering if there is > > a short trick to this in Perl. ( I know IPC::OpenX returns pid and I can do > > a waitpid on it ) . > > > > How do you mean "short trick" ... it seems IPC::OpenX would be the short trick, the normal way will work as you mentioned, to fork, and then waitpid on that child, of course within that fork you are probably still looking at doing a 'system'. 'system' just encapsulates the fork/waitpid process for you, so you don't gain anything by first forking. To maintain the shell's environment if this can't be handled in Perl, you may be able to string commands together in one command to system separated by ;'s like on the command line, but this I am not sure about. > > HTH a little, Good luck... > > http://danconia.org > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]