SitePoint Sponsor

User Tag List

Page 1 of 2 12 LastLast
Results 1 to 25 of 30
  1. #1
    SitePoint Zealot trigger8's Avatar
    Join Date
    Nov 2000
    Location
    Dallas, TX
    Posts
    133
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Automated process to LOAD text file into MySQL table

    Please help.
    Trigger8

    **************************
    I killed a 6-pack just to watch it die!

  2. #2
    imagine no limitations exbabylon's Avatar
    Join Date
    Dec 2000
    Location
    Idaho, USA
    Posts
    452
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try this perhaps:

    PHP Code:
    // connect to database

    $file "/home/user/data/spreadsheet.csv";

    if(
    $var == $foo){
        
    $command "LOAD DATA INFILE $file INTO TABLE $table";
        if(!
    mysql_query($command)){
           echo(
    "Error");
        }else{
            echo(
    "Success");
        }

    Last edited by exbabylon; Aug 22, 2001 at 17:10.
    Blamestorming: Sitting around in a group discussing why a deadline was missed or a project failed and who was responsible.

    Exbabylon- Professional Internet Services

  3. #3
    SitePoint Zealot trigger8's Avatar
    Join Date
    Nov 2000
    Location
    Dallas, TX
    Posts
    133
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Cron, Scheduled task ....

    Thanks, I'm aware of that method....but how to make it run on its own like for every 10 minutes?
    Trigger8

    **************************
    I killed a 6-pack just to watch it die!

  4. #4
    imagine no limitations exbabylon's Avatar
    Join Date
    Dec 2000
    Location
    Idaho, USA
    Posts
    452
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just like you said, use cron to call up that PHP file via HTTP every ten minutes.
    Blamestorming: Sitting around in a group discussing why a deadline was missed or a project failed and who was responsible.

    Exbabylon- Professional Internet Services

  5. #5
    SitePoint Zealot trigger8's Avatar
    Join Date
    Nov 2000
    Location
    Dallas, TX
    Posts
    133
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Are you familiar with calling up php via http in cron? Any example would be helpful.

    Thanks!
    Trigger8

    **************************
    I killed a 6-pack just to watch it die!

  6. #6
    imagine no limitations exbabylon's Avatar
    Join Date
    Dec 2000
    Location
    Idaho, USA
    Posts
    452
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Actually the best way to run it, IF you have access to cron on the server where your php script resides, is to call it up via the file path of the php script. Do you know how to set cron jobs, or have a part in your control panel to do this? If so, then for the command line in the cron job, just enter the path to your php script: ie /home/usr/update.php, or you can also call it like this in your cron: http://www.domain.com/update.php
    Blamestorming: Sitting around in a group discussing why a deadline was missed or a project failed and who was responsible.

    Exbabylon- Professional Internet Services

  7. #7
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Unless you have a php binary running on your server you'll need to call it through HTTP like exbabylon suggested for the second option. You cannot simply put the path to the file like he first suggested. The server won't know what to do with. If you did have a php binary you could do

    /path/to/php /path/to/script.php

    Your best option though is to use lynx and cron together.


    lynx http://www.domain.com/script.php >> /dev/null
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  8. #8
    imagine no limitations exbabylon's Avatar
    Join Date
    Dec 2000
    Location
    Idaho, USA
    Posts
    452
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    doh, sorry.. I forget that some don't have that. my bad.

    Yes, what freddy suggested is perfect!
    Blamestorming: Sitting around in a group discussing why a deadline was missed or a project failed and who was responsible.

    Exbabylon- Professional Internet Services

  9. #9
    SitePoint Zealot trigger8's Avatar
    Join Date
    Nov 2000
    Location
    Dallas, TX
    Posts
    133
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What is lynx?
    Trigger8

    **************************
    I killed a 6-pack just to watch it die!

  10. #10
    SitePoint Zealot trigger8's Avatar
    Join Date
    Nov 2000
    Location
    Dallas, TX
    Posts
    133
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I tried to use 'lynx' but I got this message:
    Your terminal lacks the ability to clear the screen or position the cursor.

    I use this for my cron job...is there anything wrong with it?
    0-59 * * * * http://path.to/cron.php

    I get this error message:
    /bin/sh: http://path.to/cron.php: No such file or directory

    but the file is actually there.

    Any idea?
    Trigger8

    **************************
    I killed a 6-pack just to watch it die!

  11. #11
    SitePoint Zealot trigger8's Avatar
    Join Date
    Nov 2000
    Location
    Dallas, TX
    Posts
    133
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I tried to use this too:
    /path.to/cron.php

    but still I got an error message in my email:
    /bin/sh: /path.to/cron.php: Permission denied

    Please help!!
    Trigger8

    **************************
    I killed a 6-pack just to watch it die!

  12. #12
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Make sure the file has execute privileges.

    chmod +x filename


    Also if you are using a php binary it would be
    /path/to/php /path/to/script.php


    If you use lynx it should be

    lynx http://path.to/cron.php >> /dev/null
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  13. #13
    SitePoint Zealot trigger8's Avatar
    Join Date
    Nov 2000
    Location
    Dallas, TX
    Posts
    133
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    How do I find out the /path/to/php?
    Trigger8

    **************************
    I killed a 6-pack just to watch it die!

  14. #14
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Chances are its already in your path, IF YOU HAVE A BINARY INSTALLED.

    I would try this in these steps.

    1) Login using SSH or telnet. Then try just typing in the command
    Code:
    php /path/to/your/script/script.php
    If you don't get an error then the php binary is in your path and you can omit the path part before the word php in your cron job.

    2) If it throws an error, try doing a locate php. You should geta bunch of files with php in it, look for the one that is just plain old php should be in one of your bins. Again ONLY IF YOU HAVE THE BINARY INSTALLED. If its in a folder thats not in your path you'll need to specify the complete path to the binary.


    3) If you make it through that part and its not installed, then use lynx.
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  15. #15
    SitePoint Addict jamesbond's Avatar
    Join Date
    Feb 2001
    Location
    The Netherlands
    Posts
    256
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    phpinfo will give you lots of information :

    http://www.php.net/manual/en/function.phpinfo.php

  16. #16
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Except for where your PHP binary is located.
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  17. #17
    SitePoint Zealot trigger8's Avatar
    Join Date
    Nov 2000
    Location
    Dallas, TX
    Posts
    133
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I found the path to php and used it in the cron but nothing happen. I didn't even get an error message in the email.


    This is what I get if I use lynx:
    Your terminal lacks the ability to clear the screen or position the cursor.

    Why?
    Trigger8

    **************************
    I killed a 6-pack just to watch it die!

  18. #18
    SitePoint Zealot trigger8's Avatar
    Join Date
    Nov 2000
    Location
    Dallas, TX
    Posts
    133
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    /usr/local/php-4.0.0 ?
    Trigger8

    **************************
    I killed a 6-pack just to watch it die!

  19. #19
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Is your binary setup with mysql support?

    Thats the name of your binary? Are you sure that is a binary and not a folder?

    Anyways here is a simple test.


    fropm the commandline create a file named phpinfo.php then do

    php phpinfo.php > someotherfile.php


    This will dump a copy of the phpinfo that the binary produces into a file named someotherfile.php Move that to a web accessiblel location and view it, it will tell you everything that the binary is set up to handle.

    As for the lynx issue, I would talk to your host and see whats up? can you do a lynx http://www.yahoo.com and get anything?
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  20. #20
    SitePoint Zealot trigger8's Avatar
    Join Date
    Nov 2000
    Location
    Dallas, TX
    Posts
    133
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you're right. It's a directory.

    '/bin/sh: /usr/local/php-4.0.0: is a directory'


    Yes, I can do lynx yahoo.com and get everything.
    Trigger8

    **************************
    I killed a 6-pack just to watch it die!

  21. #21
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Okay so lynx appears to be working, you are specifying the HTTP path to the file correct?

    lynx -dump http://www.yourdomain.com/yourscript.php >> /dev/null
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  22. #22
    SitePoint Zealot trigger8's Avatar
    Join Date
    Nov 2000
    Location
    Dallas, TX
    Posts
    133
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I did but I got this error message:
    Your terminal lacks the ability to clear the screen or position the cursor.
    Trigger8

    **************************
    I killed a 6-pack just to watch it die!

  23. #23
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Okay so what happenes when you just do
    lynx http://yourdomain.com/yourscript.php

    Do you get the same error? And have you tried it exactly like I have typed above or did you try some ammended verion of it?
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  24. #24
    SitePoint Zealot trigger8's Avatar
    Join Date
    Nov 2000
    Location
    Dallas, TX
    Posts
    133
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes, I typed the exact version.

    I still get the same error for using this:
    lynx http://yourdomain.com/yourscript.php
    Trigger8

    **************************
    I killed a 6-pack just to watch it die!

  25. #25
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I really don't want to sound like a jerk here, but since I haven't seen you replace the url with a real one yet, you are putting a valid domain and script name in here right? Could you post the exact line you used I can try it from here and see if its your system or if you are doing something wrong.
    Please don't PM me with questions.
    Use the forums, that is what they are here for.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •