I'm helping to build a Django app that will interface with a voip phone system, and they've created some scripts to execute when an action is performed (add, update,delete) in order to have parity with the phone system side. They've asked me to pass the parameters to the script like this
/var/www/html/om/om_add.sh deviceid filename title
They've also mentioned to pass the title as a url, using urllib.quote_plus(title)
Lastly, it should occur after each action is executed in the app.
Now, I've heard that executing shell scripts from a Django app is not advised, but wondering if this is a different case? Also, how I can go about doing this, the only way I know how to pass those params is to pass them through a view. Any help is greatly appreciated!
def post_create(request):
device = request.session['device']
if device == 'dummy':
return render(request,'access_denied.html')
did = {'device_id': device }
form= PostForm(request.POST or None, request.FILES or None,initial=did)
if form.is_valid():
instance = form.save(commit=False)
check = Sounds.objects.all().filter(device_id= device).filter(target=instance.target).exclude(target='generic').first()
if check:
instance.pk = check.pk
instance.device_id= device
instance.save()
return HttpResponseRedirect('/')
else:
instance.device_id = device
instance.save()
dev = instance.device_id
name = instance.sound.name
title = urllib.quote_plus(instance.title)
os.execv('/var/www/html/ogm/ogm_add.sh', [dev,name,title])
return HttpResponseRedirect('/')
context= {
'form': form,
}
return render(request, 'post_form.html',context,)