LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 12-05-2003, 09:29 AM   #1
paulvl
LQ Newbie
 
Registered: Aug 2003
Location: The Netherlands, Zoetermeer (15Km East from The Hague)
Distribution: Red Hat Linux release 9 (Shrike) (Kernel 2.4.20-8 on an i686)
Posts: 27

Rep: Reputation: 15
RH: Trying to make script to remotely modifie mysql db.


Hey dudes,
Hope you guy's can give me some clue's on this one:

I'm trying to make a shellscript that executes an (update) SQL statement on a (remote) MySQL database.

Right now I got the thing fixed like:
- A php script sending the SQL
- A shell script like "lynx http://localhost/sendsql.php"

But now I would like to do it without the lynx and preferably without using a php page.

Does anyone know how to do this? I'm just a little n00b so might very well be that I'm trying the impossible. If so, please say so.

Hope hearing from ya. Thnx anyway for reading.

GrTzzz... Paulvl
 
Old 12-05-2003, 10:08 AM   #2
paulvl
LQ Newbie
 
Registered: Aug 2003
Location: The Netherlands, Zoetermeer (15Km East from The Hague)
Distribution: Red Hat Linux release 9 (Shrike) (Kernel 2.4.20-8 on an i686)
Posts: 27

Original Poster
Rep: Reputation: 15
Maybe there is another way so I will clarify my goal to make sure the above question is the right path to take.

The situation is quite standard I gues. I have a Lan with some pc's. One of them is running as a linux server (php, mysql, ... stuff like that)
All pc's are connected to a router which grands access to the internet.

All fine so far...

Shitty thing is my ISP has dynamic IP. I like the advantages, but I need to be able to access my Lan (read: server) from the outside.

Right now I'm doing:
A shell script:
Code:
i=1
while [ $i -le 10 ]
do
      lynx http://vk26dellserver/paul/ipopslaan.php &
      date &
      sleep 600
done
(I got this script somewhere... It's like a black box to me. I know what it does... That's all)

The php script:
Code:
<?PHP
MYSQL_CONNECT("mysql.frandt.com","[username]","[password]") OR DIE ("database benadering is mislukt.");
$db = MYSQL_SELECT_DB("ipaddress") OR DIE ("database benadering is mislukt");

$file = fopen ("http://www.whatismyip.com/", "r");
while (!feof ($file)) {
    $line = fgets ($file, 1024);
    /* This only works if the title and its tags are on one line */
    if (eregi ("<title>(.*)</title>", $line, $out)) {
        $title = $out[1];
        break;
    }
}
fclose($file);
$ipaddress = "";
$teller = 11;
while($title{$teller}!=' ')
{
	$ipaddress=$ipaddress.$title{$teller};
	$teller++;
}
$het_nu = getdate();
MYSQL_QUERY("UPDATE ipaddress SET ipaddress='".$ipaddress."', date_year=".$het_nu["year"].", date_month='".$het_nu["month"]."', date_day=".$het_nu["mday"].", date_hour=".$het_nu["hours"].", date_minute=".$het_nu["minutes"].", date_second=".$het_nu["seconds"].";")
?>
----------------------------------------------------------------------

All works, but I think there should be a better way to solve my IP problem. Can anyone help?
Thnx in advance

Paulvl
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Remotely connecting to MySQL using SSH Teleute Linux - Security 19 03-25-2005 10:51 PM
Log in to mysql remotely chamalsl Linux - Security 6 03-23-2005 01:40 PM
Accessing MySQL remotely: good programs? seppuku Red Hat 1 11-11-2003 08:34 AM
Can't connect to MySQL server remotely on RedHat 9 bper Red Hat 4 10-02-2003 10:56 AM
conecting to MySQL remotely dsiguy Linux - General 2 02-24-2003 07:59 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 09:08 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration