Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place! |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
12-17-2009, 07:10 PM
|
#1
|
LQ Newbie
Registered: Nov 2009
Posts: 11
Rep:
|
Count files in dir then move that many files in a script?
Hello World,
K, this is what I got - from a crontab run a script (understand that part), this script needs to count the amount of files in /outgoing/, then take 30 less that number, and move that many files from /readycalls/.
I need to keep the asterisk outgoing que full of .call files with out having to many in there at any given time.
Any help would be awesome!!
|
|
|
12-17-2009, 08:09 PM
|
#2
|
Moderator
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
|
I don't know anything about astrisk and its inner workings,
but to me moving 30 random files from a spool sounds like
trouble in the making. Can you be more specific with your
requirements?
Cheers,
Tink
|
|
|
12-18-2009, 08:57 AM
|
#3
|
LQ Newbie
Registered: May 2009
Posts: 3
Rep:
|
In bash I use
Code:
#!/bin/bash
TOTAL_CALLS_CMD=$(find /outgoing/ -mindepth 1 -maxdepth 1 -type f | wc -l)
declare -i REDUCED=$TOTAL_CALLS_CMD-30
echo Total: $TOTAL_CALLS_CMD
echo Reduced: $REDUCED
Then you could use a while loop for while TOTAL_CALLS_CMD -gt $REDUCED move a file or however you need to do that.
You should also of course make sure there is more than 30 to begin with, etc.
Last edited by Doc Kaos; 12-18-2009 at 08:59 AM.
Reason: Missed slash in code
|
|
|
12-18-2009, 11:31 AM
|
#4
|
LQ Newbie
Registered: Nov 2009
Posts: 11
Original Poster
Rep:
|
Thanks for the code! I will see if I can make that work.
In regards to how and why, its actually a very simple procedure. Asterisk has a directory /var/spool/asterisk/outgoing/ , when you drop a properly formated .call file into the dir, it follows the specified .call file and makes an outbound call. Its how you initiate outbound calling in asterisk.
That being said, I am building an alert system for the public school district I administer, this system is managed via a web based 'wizard' that I have made. It also send sms txts, and emails to registered users. When the alert is configured, it drops all of the appropriate .call files into a temp directory, a coulple thousand. Then a cron job moves those files into the outgoing directory every 1 min. However, if there are more calls trying to get made than the amount of channels (phone lines) available, it will just skip the call. So, If i dropped in 2000 call files, with only 40 channels available, it would only make 40 calls. So, I need just need to drop in no more than 30-40 at a time. Hence the requested bash script.
|
|
|
All times are GMT -5. The time now is 08:40 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|