Stop using sudo everywhere, you also don't give your home or car keys to everyone you know...there is only 1 sudo needed as to install in /local/usr/bin you typically need elevated rights to write to...for all the rest you don't need sudo.
Just make the file I send you executable with chmod (without sudo, not needed) (also better rename it to sh), should work at least here it does.
Also I don't build anymore in the script in /local/usr/bin, but just in your home folder. Makes much more sense.
Also this will be the last time I help in this thread for building some oscam...this has nothing to do with Dvbivewer, dvbapinet and the setup this thread is about.
Make new threads open with your questions, because it is off topic here.
So if you have more questions regarding the script, I will just ignore them in this thread.
EDIT 1 motre comment to my script: probably you will need to add a config folder (or some where with read/write access) in the home dir with your configs
so when starting oscam add "-c ~/oscam-configs" or so.
mkdir -p ~/oscam-configs
/usr/local/bin/oscam -b -c ~/oscam-configs/