Bash Scripting

Lynn David Newton plug-discuss@lists.plug.phoenix.az.us
Sun, 14 Apr 2002 00:44:10 -0700


  b> Unfortunately, bash doesn't put the executed
  b> output in the variable, it puts the text itself
  b> in. Any other ideas?

I see in later mail you found a solution, but I see a
problem here. 

  >> #!/bin/sh
  >> 
  >> USER=bryce
  >> NFSMOUNT=somenfsmount
  >> FILENAME=somefilename
  >> COMPUTERNAME=`uname -n`
  >> DATE=`date +%m-%d-%y`
  >> DIRECTORYTOBU=somedirectorytobu
  >> 
  >> su $USER -c "cd /home/$USER; tar czf \
  >> $NFSMOUNT/$FILENAME.$COMPUTERNAME.$DATE.tar.gz $DIRECTORYTOBU/"

Does the last statement get the values set? su runs in
a subshell. Isn't it necessary to export the variables
for this to work?

I haven't played with it myself, so I don't know the
answer, but I do recall dealing with this very thing in
a script I wrote about 15 years ago. Anything I
expected to carry over into the su I had to export.

-- 
Lynn David Newton
Phoenix, AZ