rubing
-
Posts
366 -
Joined
-
Last visited
Never
Posts posted by rubing
-
-
Hey Thorpe!
How's the php 5.3 install working?
well, I changed that script to read as follows:
Script blacknet:
#!/bin/bash
#start bcharge up and send any output to the void
bcharge &> /dev/null
THERE=$?
echo "checking for phone..."
if [ $THERE -eq 0 ];
then
echo "yay, we found you're phone"
#kill any running instances of ppp, before starting it up
pkill ppp*
pppd call barry-sprint&
else
echo "boo, we didn't find jack"
#this needs to sleep and check again first
fi
It works, but it runs entirely in the background. So that if I type blacknet. I get returned to a prompt and then as commands get executed they pop up. I would rather the program take away the prompt until its finished running.
-
Yo homeys.
I am a linux programming noob, greener than your lawn, although i do know php, so not a complete rube. I am hoping I can get some help on writing my first script.
I am using a blackberry to get internet on my laptop (tethering). I am damn damn sick and damn damn infuriated at having to always type the commands manually. So, I wrote the following script:
#!/bin/bash bcharge pppd call barry-sprint&
This works, but is not really robust. First, I really need to be able to check whether or not bcharge finds a phone plugged in. If it doesn't detect anything then i'd want to wait a couple secs and try again, before failing gracefully. Well, you don't need to hear about all that. Basically I just want to know how to check whether the phone is plugged in. Is this what they call exit status??
-
ooops. looks like this is an ubuntu specific bug.
found a solution here: http://ubuntuforums.org/showthread.php?t=573878&page=2#12
-
I am running php on ubuntu 8.04. After typing pear remote-list, I received the following warning:
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20060613/imagick.so' - libWand.so.9: cannot open shared object file: No such file or directory in Unknown on line 0
-
I am downloading resources with CURL, WGET, etc...
Some of these resources are pages that execute asynchronous requests vis a vis Flash or Ajax. How do I retrieve info on all of these asynchronous transactions on the resource I am downloading?
-
yup. works great!! apreciate it scott!!! thanks.
-
good evening folks.
I have a website, which logs a lot of client info to a mysql database. I want to offer these logs to the client as a file download (csv, sql, whatever...)
so, I know its easy to create a dump file of a database with the mysql dump command. But I am confused as to how to let a customer download a dump of their customer data.
I guess basically I am asking how do I get php to present a file for download to the client???
-
interesting read...but not much on my problem.
-
yes, it works fine if i define it relative. but I am going to be moving these scripts and so need to define the paths absolutely?
-
I have a php script running in a public directory: /home/ted/public_html/myphpsript.php
This script requires a php script located in a private directory
require_once '/home/ted/lib/merge_mp3.inc';
running myphpscript.php I am getting the following error:
Warning: fopen(./played/CaddleWORK2.mp3) [function.fopen]: failed to open stream: No such file or directory in /home/rubing/lib/merge_mp3.inc on line 481
The script being required (the one in my private directroy) is trying to save the file to it's own directory. But my document root is set to /home/ted/public_html???
-
SWEET!!!
-
I have a php script running in a public directory: /home/ted/public_html/myphpsript.php
This script includes a separate php script in a non-public directoy:
require_once '/home/ted/lib/merge_mp3.inc';
When I run myphpscript.php I get the following error:
Warning: file_get_contents(/home/ted/public_html/CaddleWORK.mp3) [function.file-get-contents]: failed to open stream: No such file or directory in /home/ted/lib/merge_mp3.inc on line 12
It seems this script is considering /home/public_html/CaddleWORK.mp3 as a relative URL. How can I change that???
-
I guess I was a little bit concerned b/c I have often read that crawlers, spiders, bots, etc... which ignore your rules....sorry should've been more specific. Last year I was browsing a book about webbots and the mentioned that some sites employ advanced methods for detecting them. I guess its silly though to worry about such a potentially small source of traffic!
I like the isSpider function!
-
I am trying to build a simple ad server in php. How do I exclude looging the activity of any spiders, bots, etc...
Is there an easy way to exclude all of them using the SERVER variables or something of that nature??
thx!
-
If I change COUNT(*) to COUNT(ad_log.ad_played), then it works perfect! otherwise it counts null values (unplayed ads) as being played. THanks so much fenway for this elegant solution!!!!
I had no idea that you could join on 2 different conditions like that.
SELECT
ad.ad_id, ad.owner_api, ad_log.sess_id, COUNT(ad_log.ad_played) AS num_times_played
FROM ad
LEFT JOIN ad_log ON ( ad_log.ad_played = ad.ad_id AND ad_log.sess_id = 5 )
WHERE ad.owner_api = 1
GROUP BY ad.ad_id
-
I have the following 2 tables, where ad_id = ad_played. I want to know how many times sess_id=5 has played each ad of owner_api =1
TABLE ad:
ad_id owner_api
1 0
2 1
3 1
4 1
5 5
6 5
TABLE ad_log:
sess_id ad_played
1 2
1 2
5 3
5 2
5 5
6 5
6 5
6 6
7 5
7 3
1 5
1 5
My Result table should look like this:
ad_Id owner_api sess_id num_times_played
2 1 5 1
3 1 5 1
4 1 5 0
-
I was thinking along those lines, but the only the only field these three tables have in common is the id field. the session field is unique to the ad_log table. I thought I could only JOIN on fields which were the equivalent
-
sure! should i send it to your email? what form csv??
-
Well, how would I select for ad_id (TABLE ad) where ad_id has no corresponding ad_played (TABLE ad_log) entry for sess_id = 5
???
-
1. I want to select all the ads from owner_api (all of a single advertisers ads).
2. I want to select which of these ads been played least by the sess_id (browser's session id) by this client. (In table ad_log a single log entry is made every time an ad is played.)
3. I want to eliminate ads that have been played too many times per this clients session.
As I showed you before I can select for the least played ads without a problem. However, when I do that I fail to bring up the ads that haven't played at all.
again, here are my 3 tables (better fromatted), where ad_id = ad_played = advert_id
TABLE ad:
ad_id owner_api file plays_purchased times_played
1 0 cmn.mp3 0 0
2 1 dumb.mp3 8 4
3 1 stupid.mp3 0 0
4 1 crazy.mp3 10000 0
5 5 wild.mp3 1787 333
6 5 justin.mp3 22 22
TABLE ad_log:
ipaddress sess_id ad_played date_played
11 1 2 2008-08-31 11:35:44
11 1 2 2008-08-31 11:35:44
55 5 3 2008-08-31 11:36:20
55 5 2 2008-08-31 11:35:44
55 5 5 2008-08-31 11:35:44
66 6 5 2008-08-31 11:35:44
66 6 5 2008-08-31 11:35:44
66 6 6 2008-08-31 11:35:44
77 7 5 2008-08-31 11:35:44
77 7 3 2008-08-31 11:35:44
11 1 5 2008-08-31 12:09:11
11 1 5 2008-08-31 12:09:11
Table ad_limit:
advert_id plays_per_session
1 3
2 3
3 4
4 5
6 2
-
Do you mean i should do a different kind of join. I heard that a cross join is too taxing on the resources.
-
Should do what you want as long as your WHERE Clause is just the session_id and that session_id has a count >0 which if it doesn't it doesn't exist technically for you.
That's the problem! If I change the query to include the limits you suggest (changes in red)
SELECT ad.ad_id, ad.owner_api, ad.file, sess_id, plays_per_session, count( * ) AS played
FROM (ad LEFT JOIN ad_log ON ad.ad_id = ad_log.ad_played)
LEFT JOIN ad_limit ON ad.ad_id = ad_limit.advert_id
WHERE owner_api =1
AND sess_id =5
GROUP BY sess_id, ad_id
ORDER BY played ASC
Then my results set will look as follows:
ad_id owner_api file sess_id plays_per_session played
3 1 stupid.mp3 5 4 1
2 1 dumb.mp3 5 3 3
The problem with this result list is that it's missing ad_id number 4, crazy.mp3, which is the one that should played, since it's been played the least (0 times). Unfortunately, this query only brings up ads that session 5 has played at least once.
-
OK, that's great!!! it works now, which means i can ask the second part of my question (i swear there are only 2 parts!!!!)
I have a third table called ad_limit, which limits the # of plays an ad will get per session. here it is:
Table ad_limit:
advert_id plays_per_session
1 3
2 3
3 4
4 5
6 2
I want to combine all three tables in such a way as to show me the least played ad for a particular session id. (of course so I can serve it to them! )
So, if i execute the following SQL:
SELECT ad.ad_id, ad.owner_api, ad.file,sess_id,plays_per_session,count(*) AS played FROM (ad LEFT JOIN ad_log ON ad.ad_id = ad_log.ad_played) LEFT JOIN ad_limit ON ad.ad_id=ad_limit.advert_id WHERE owner_api=1 Group BY sess_id,ad_id
I get a nice little list of the number of times an ad's been played for any session that's happened to play them:
ad_id owner_api file sess_id plays_per_session played
4 1 crazy.mp3 NULL 5 1
2 1 dumb.mp3 1 3 2
2 1 dumb.mp3 5 3 3
3 1 stupid.mp3 5 4 1
3 1 stupid.mp3 7 4 1
Great! But really, I am only interested in a single sess_id number....let's say 5. I want to show the ad that's been played the least by sess_id 5. In this case it would be ad_id 4, since sess_id has not played this song yet.
If I try to filter the list by specifying sess_id =5 in my WHERE clause, then ad_id 4 doesnt' even show up. b/c of course in that case it's will only show ads that have been played by 5. I think this is a tricky problem ???
-
OK, this is really pissing me off!!!!!
I am executing this SQL:
SELECT ad.ad_id, ad.owner_api, ad.file, ad_log.ad_played, COUNT( ad_played ) FROM ad LEFT JOIN ad_log ON ad.ad_id = ad_log.ad_played GROUP BY ad_played
here are my 2 tables (sorry had trouble posting them with correct aligning)
TABLE ad:
ad_id owner_api file plays_purchased times_played
1 0 cmn.mp3 0 0
2 1 dumb.mp3 8 4
3 1 stupid.mp3 0 0
4 1 crazy.mp3 10000 0
5 5 wild.mp3 1787 333
6 5 justin.mp3 22 22
TABLE ad_log:
ipaddress sess_id ad_played date_played
11 1 2 2008-08-31 11:35:44
11 1 2 2008-08-31 11:35:44
55 5 3 2008-08-31 11:36:20
55 5 2 2008-08-31 11:35:44
55 5 5 2008-08-31 11:35:44
66 6 5 2008-08-31 11:35:44
66 6 5 2008-08-31 11:35:44
66 6 6 2008-08-31 11:35:44
77 7 5 2008-08-31 11:35:44
77 7 3 2008-08-31 11:35:44
11 1 5 2008-08-31 12:09:11
11 1 5 2008-08-31 12:09:11
And here is the result of my query:
ad_id owner_api file ad_played COUNT(ad_played)
1 0 cmn.mp3 NULL 0
2 1 dumb.mp3 2 3
3 1 stupid.mp3 3 2
5 5 wild.mp3 5 6
6 5 justin.mp3 6 1
So, my problem is this: Why the hell isn't ad_id 4 showing up in my results table???? ARGHHHHHHH!!!!! >
check exit status
in Linux
Posted
hmmm...this isn't quite doing what I want, b/c the prompt is not returned at the very end. It just kind of hangs there saying:
/etc/ppp/ip-up finished