If you have ever come across a text file that has some unnecessary characters added before file/directory paths & you need to get rid of that, how would you do it? E.g.
Easy way, just edit the file and that’s it 😀
Good one 🙂 But what if the file has hundreds of lines? 😉
So, below is how to do it inside Vi editor 🙂 Open the file & issue this –
Mission accomplished 😀
Since there was ./ in path, we escaped that using \ Then there were two // so we escaped them using \/\/ And since we had to replace it with a /, we added another /\/
Syntax of replacing text in Vi is –
If you have tried running Oracle sqlplus (of course through a script) in a cron job, then you might have encountered this error: –
sqlplus: error while loading shared libraries: libsqlplus.so: cannot open shared object file: No such file or directory
What happens is that, despite defining all the environment variables in /etc/profile or bash_profile, cron doesn’t recognise that & throws above error. Close inspection after debugging the script took me to a conclusion that sqlplus is not able to connect to database, because its not finding its shared library.
If you have encountered this issue, here is how to fix it? 😉
Make sure you have exported required variables. Below are my variables in my .bash_profile. Change yours accordingly.
Make sure you source your .bash_profile before executing the script in cron. Edit your script & add below line at the top.
Now try executing the script in cron. It will be successful 😉 cron will first source the bash_profile, initialise all the variables & then execute the script 🙂