I'm seeing some really strange behavior in a script I'm working on.What I have is an svn hook that gets run whenever a commit is made to an svn repo. It runs a sqsh command that generates another script (checkout.sh) and then executes that generated script. If I just run the script manually I get a result like this for the generated script:
/usr/bin/install -d /opt/www/targetRepo/svn/targetDir1; /usr/bin/svn checkout http://mysite.com/svn/sourceRepo/targetDir1 /opt/www/targetRepo/svn/targetDir1; /usr/bin/install -d /opt/www/targetRepo/svn/targetDir2; /usr/bin/svn checkout http://mysite.com/svn/srcRepo/targetDir2 /opt/www/targetRepo/svn/targetDir2;
Notice How each line ends with a semi-colon.
If I run the same script but preface it with /usr/bin/sudo -u myname
then the generated script replaces the semicolon at the end of each line with a pipe '|' character. As a result, when the main script tries to actually execute that generated script it fails with an 'invalid end of file' error.
Update Here are the scripts I'm trying to run:
sudo-hook.sh
#!/bin/bash
/usr/bin/sqsh -o ./checkout.sh -w 999999 -h -S myserver -D mydb -U dbuser -P apassword -C "select distinct '/usr/bin/install -d /opt/www/targetRepo/svn/'+cast(p.id as varchar(32) )+'; /usr/bin/svn checkout http://mysite.com/svn/srcRepo/'+cast(p.id as varchar(32) )+' /opt/www/targetRepo/svn/'+cast(p.id as varchar(32) ) from frame_skus as sku join products as p on p.id=sku.frame_id join frame_colors as c on c.id=sku.color_id join frame_sizes as s on s.id=sku.size_id join value_options as cc on c.color_code_id=cc.id join product_files as img on img.product_id=p.id and img.color_id=c.id and img.dtype='FRAME_IMAGE' join brands as b on p.brand_id=b.id and b.id=69;"
./checkout.sh
checkout.sh (the generated script):
/usr/bin/install -d /opt/www/targetRepo/svn/31903; /usr/bin/svn checkout http://mysite.com/svn/31903 /opt/www/targetRepo/svn/31903|
/usr/bin/install -d /opt/www/targetRepo/svn/31904; /usr/bin/svn checkout http://mysite.com/svn/31904 /opt/www/targetRepo/svn/31904|
/usr/bin/install -d /opt/www/targetRepo/svn/31905; /usr/bin/svn checkout http://mysite.com/svn/31905 /opt/www/targetRepo/svn/31905|
Can someone please give me an idea of what is going on here?