System info: Linux slackware R Version 1.6.0 (2002-10-01) ESS 5.1.21 Emacs 21.2.1 ------------------- Colleagues Can anyone tell me what R does with local variables when they are passed in a system call to a shell script? e.g. I have a string as an R variable called tripcode. I want to pass this variable in a system call to a local bash script calling gmt (Generic Mapping Tool) functions: system("source map_acoustic_transects_and_trawls.gmt", tripcode) I think this is what is meant in Section 4.6 of Venables and Ripley(?). When I ECHO the parameter passed into the bash script nothing is returned: echo "TripCode" $tripcode TripCode Is there a way to do this efficiently without writing the string variable to a file and re-reading it into the shell script? Thanks for advice, Sam -- Sam McClatchie, Research scientist (fisheries acoustics)))))))))) NIWA (National Institute of Water & Atmospheric Research Ltd) PO Box 14 901, Kilbirnie, Wellington, New Zealand s.mcclatchie at niwa.cri.nz Research home page <http://www.smcc.150m.com/> /\ >><xX(&> /// \\\ //// \\\\ /// <%)Xx><< ///// \\\\\\ ><(((@> ><(((%> ..>><xX(?>O<?)Xx><<
Hi, | From: Sam McClatchie <s.mcclatchie at niwa.co.nz> | Date: Tue, 10 Dec 2002 10:03:48 +1300 | | Can anyone tell me what R does with local variables when they are passed | in a system call to a shell script? | | e.g. I have a string as an R variable called tripcode. I want to pass | this variable in a system call to a local bash script calling gmt | (Generic Mapping Tool) functions: | | system("source map_acoustic_transects_and_trawls.gmt", tripcode) You are missing paste() here. Look ?paste. E.g. a <- "-l"> system("ls", a)10-doc funktsioonid.R~ lave-spell Overview.dvi andmed gauss-analyse.tar.gz lave-spell.tar.gz Overview.log artikkel2 gauss-analyse.tar.gz~ Leifi_kirjad.txt Overview.tex ...> system(paste("ls", a))total 488 drwxrwxr-x 2 otoomet otoomet 4096 dets 5 14:19 10-doc drwxrwxr-x 3 otoomet otoomet 4096 nov 19 15:46 andmed drwxrwxr-x 3 otoomet otoomet 4096 dets 5 12:44 artikkel2 drwxrwxr-x 2 otoomet otoomet 4096 dets 5 07:03 bilder ... | I think this is what is meant in Section 4.6 of Venables and Ripley(?). | | When I ECHO the parameter passed into the bash script nothing is returned: | | echo "TripCode" $tripcode | TripCode | | Is there a way to do this efficiently without writing the string | variable to a file and re-reading it into the shell script? Ott