Echo Number Calling using which CID on Bash

Hello,

I have a specific callfile and when it’s calling I would like it to display the actual number that it’s dialing with which caller ID. Any one has any idea on how to do that?

So far, I have this:

#!/bin/bash
COUNTER=$1
for (( c=1; c<=COUNTER; c++))
do
cp callfile.bak callfile.call
chmod 777 callfile.call
chown asterisk:asterisk callfile.call
mv callfile.call /var/spool/asterisk/outgoing/
sleep 3
echo “Calling…”
done

Thanks!

What you are trying to accomplish is not clear. Where do you want the DID and CID displayed? Your script does not set or use either.

Don’t do this. It shows a lack of understanding of the implications of permissions. There is no need and it opens a window for bad things to happen.

This shows that you are executing this script as root. Another bad idea, and combined with the above, opens a window for really bad things to happen. Maybe not worse than above, but it gives me the ‘willies’ when scripts execute as root with obvious security flaws :slight_smile:

If this is where you want the DID and CID displayed, they have to be variables in the script and inserted into the appropriate places in the call file.

See if this points you in the right direction:

#!/bin/bash                                                                                                                                                                  

# create a unique file                                                                                                                                                       
# (assumes /tmp/ is on the same partition as 'astspooldir')                                                                                                                  
        call_file=$(mktemp)

# create the call file content                                                                                                                                               
        (
        printf 'channel:\ttechnology/%s@provider\n' $1
        printf 'callerid:\t"Just a test call"<%s>\n' $2
        ) >${call_file}

# give it to asterisk                                                                                                                                                        
        sudo chown asterisk:asterisk ${call_file}
        sudo mv ${call_file} /var/spool/asterisk/outgoing/
 
# cleanup                                                                                                                                                                    
        rm ${call_file}

# say what we did                                                                                                                                                            
        printf 'Calling %s as %s\n' $1 $2

Here’s another way to handle the ‘personalization’:

        sed\
                --expression="s/placeholder1/$1/g"\
                --expression="s/placeholder2/$2/g"\
                <callfile.bak\
                >callfile

i know what you’re saying but this is an internal system so I don’t have to worry about all that. I just need to be able to parse the phone number it’s dialing and the caller ID it’s using…

echo “Calling…”

Sorry. Still not clear…

Are you asking how to parse the CID and the DID from your call file? If so, this is a Bash question, not an Asterisk question.

And they’re always internal systems until they’re not. Like when a rookie SysAdmin copies a known vulnerable SGI (Silicon Graphics, Inc for you kids) CGI over to your Solaris production host which then gets instantly ‘owned.’

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.