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:



/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 (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?

  • 2
    Sudo resets much of the environment. Does your script rely on an Env var to generate the output?
    – Jeff Schaller
    Apr 28, 2016 at 23:01
  • 1
    You need to show us the script (and any other script that it depends on). Otherwise we can only make wild guesses. Apr 29, 2016 at 0:36
  • Ok, I added some examples for the scripts I'm trying to run.
    – pbuchheit
    Apr 29, 2016 at 12:58

1 Answer 1


Ok, I think I found the problem. Apparently it was sqsh that was adding those '|' characters. sqsh has a style (-m) flag and it seems if you don't set it explicitly then it defaults to the 'bcp' style which adds those extra characters.

What I would still like to know is why it defaults to one style 'bcp' when run with sudo but defaults to another style 'horizontal' when run without sudo.

  • Have you an SQSH environment variable set in one place but not the other? Or a ~/.sqshrc file?
    – roaima
    Apr 29, 2016 at 16:01
  • How would I check to see if that is the case?
    – pbuchheit
    Apr 29, 2016 at 16:41
  • the same way you'd check any other variable or file. echo $SQSH and cat ~/.sqshrc. Do this as yourself and then do sudo -i and repeat the two commands
    – roaima
    Sep 30, 2016 at 8:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.