ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
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.
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.
Hello All, this is my first post EVER so I apologies in advance for any newbie pet peeves. I recently installed postfix/spamass./clamav/amavisd/mysqld/php on a dedicated server and after a couple sleepless nights have my mail server running nicely. I have one problem left to solve.
I found a php file a few years ago that will display my current dynamic ip address
in order to include the zero after the IP address. What I would like this script to do now is export the "$ipad 0" to a file, lets say /etc/postfix/ipfile
I tried different variances of
echo "$ipad 0" >/etc/postfix/ipfile;
but keep getting syntax errors. Your help is greatly appreciated.
A few quick comments...
echo "$ipad 0"; is correct.
If you are using fopen() then you will want the mode to be w+ (read and write), not just read.
However a quick way would be to uses file_get_contents() and file_put_contents(). Check them out on your help file...
oops, my mistake on the fopen mode.
i prefer the concatenation with "." to putting the variables directly inside the string, but you're right, it is correct.
My problem has been solved. Here is the final php page that will show your clients IP address while at the same time write the output to a file (ie /tmp/ip.txt).
Thanks to all that replied.
<html>
<head>
<title>Get IP</title>
<style type="text/css">
body
{
background-color: white;
font-family: "verdana";
}
P
{
font-size: 10pt;
}
</style>
</head><body>
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.