Bash shell alias not working as expected -


i'm trying write shell script uses libreoffice convert .odt document .pdf, getting stuck on alias issue. have following line in ~/.bash_profile:

alias soffice='/applications/libreoffice.app/contents/macos/soffice' 

there's following line in shell script:

soffice --headless --convert-to pdf $filename 

that creates "line 14: soffice: command not found" error. i'm not sure what's going on because can call

$ alias alias soffice='/applications/libreoffice.app/contents/macos/soffice' 

and

$ soffice --headless --convert-to pdf thefile.odt 

also works fine. know why alias isn't working in script , can it? thanks.

the other answers try solve globally, add answer solve problem in current script (without aliases, shouldn't used in scripts).

the appropriate answer question might add directory path, i.e. adding ~/.bashrc @palec suggested. make alias unnecessary. if want solve this script can add path right in script! put somewhere in top of script (before running soffice command):

export path="$path:/applications/libreoffice.app/contents/macos/soffice" 

actually don't need export here.

another option setting soffice variable, i.e.:

soffice="/applications/libreoffice.app/contents/macos"  $soffice --headless --convert-to pdf thefile.odt 

...but convenience

/applications/libreoffice.app/contents/macos/soffice --headless --convert-to pdf thefile.odt 

which totally ok one-off command in personal script. wider public safer route, path, preferred.


Comments

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -