lewashby 56 Junior Poster

So how can I get the IP of the RE?

lewashby 56 Junior Poster

In my home network I have my desktop wired (eth0) to a Netgear range extender that is wirelessly linked to my Linksys AC1200 router. If I do ip route show I get the IP address of my router but not the Netgear range extender that has the association with the router. How can I get the IP address of the Netgear device?

lewashby 56 Junior Poster

Gribouillis where did the parameter mode come from in the else return line? I don't see it defined.

woooee Your program is working but it's giving me really messy output, it's all on one line an run togather. I tried pring '\n' right after the print statement but that doesn't seem to be getting the job done. Any ideas?

lewashby 56 Junior Poster

Is there a function that I can use to find out if a file is a block device? And another for a character device. I'm trying to create a funtion that will build a string the is exactly like the result you get from running ls -l for a slightly larger program I'm working on. Maybe it would save me some time if that function already existed, what would be helpful as well. Thanks.

lewashby 56 Junior Poster

In the following program why is pwd.getpwuid returning my user and group names followed by three commas? Where ar ethe commas coming from?

#!/usr/bin/python3

import os, stat, pwd

dirList = os.listdir()

permissions = (stat.filemode(os.stat(dirList[1]).st_uid))

string = permissions + ' '
string = string + dirList[1]

print(string)

temp = os.stat(dirList[1])


print(temp.st_uid)
temp2 = pwd.getpwuid(temp.st_uid)
print(temp2.pw_gecos)
lewashby 56 Junior Poster

Thanks.

lewashby 56 Junior Poster

ErrorLog ${APACHE_LOG_DIR}/error.log

This is the line in apache's configure file that creates the error.log file. I couldn't find any other references as to what ErrorLog is or how it works. If this had been a touch command or another known command I would be able to get this done pretty easily. Any ideas?

lewashby 56 Junior Poster

Does anyone know how I can set the default group for /var/log/apaches/error.log to be a part of my users group each time it is created by apache?

lewashby 56 Junior Poster
#!/usr/bin/python3

import os, stat, pwd

def list_files():
    thisDir = os.listdir()

    for current in thisDir:
        print(get_current_attr(current))
        #print(current)

def get_current_attr(file):
    line = (stat.filemode(os.stat(file).st_mode))
    line = line + '\t\t ' + (stat.filemode(os.stat(file).st_uid))
    line = line + '\t\t ' + file
    return line

print(list_files())

#END#

Why is the second line in get_current_attr() dispaying almost the exact same thing as the frist line except that it lacks the tail end None, which I atually prefer. I changed st_mode to st_uid but I'm still getting almost the same output. Thanks Woooee, I'' see if I can work that into my program.

lewashby 56 Junior Poster

(Linux)

output = os.listdir()

In the above line of code I'm getting the name of the file(s) in a given directory, but how can I also get the permissions? This is what I want to see.

-rwxr-xr-x 1 garrett garrett  158 Nov 23 10:49 dirlist.py
drwxr-xr-x 2 garrett garrett 4096 Nov 23 10:32 test.dir
-rw-r--r-- 1 garrett garrett    0 Nov 23 10:32 test.txt
lewashby 56 Junior Poster
<!DOCTYPE html>
<html>
    <head>
        <link type='text/css' rel='stylesheet' href='style.css'/>
        <title>Get Started!</title>
    </head>
    <body>
        <p><?php echo ""; ?></p>
    </body>
</html>

I thought css needed to be imbeded or linked from the <sript> tag?

lewashby 56 Junior Poster
#!/usr/bin/python3

import sys

input1 = sys.argv[1]

def print_params(*params):
    print(params)

print_params(input1)

#END#

In the above code how can I call all the command line arguments with the prin_params function without having to code input1, input2, input3, etc... When I'm doing testing liket this I would like to be able to just feed my command line arguments right inow print_params() intread of having to manually code every line. I tried print_params(sys.argv[]) but it did not work

lewashby 56 Junior Poster

That got it fixed. Thanks guys. :)

lewashby 56 Junior Poster
mysql> select * from mysql.user where User='garrett' and Host='localhost';
Empty set (0.00 sec)

mysql>
lewashby 56 Junior Poster

When I run:
---mysql> SET PASSWORD FOR 'garrett'@'localhost' = PASSWORD('abc123');
I get:
---ERROR 1133 (42000): Can't find any matching row in the user table

Also, when I run:
---mysql> UPDATE mysql.user SET Password=PASSWORD('abc123') WHERE User='garrett' AND Host='localhost';

I get:
---Query OK, 0 rows affected (0.00 sec)
---Rows matched: 0 Changed: 0 Warnings: 0

So then to test this I exit and login as my user name, garrett

mysql -u garrett -p
Enter password: abc123
---ERROR 1045 (28000): Access denied for user 'garrett'@'localhost' (using password: YES)

Any ideas?

lewashby 56 Junior Poster

I just purchased a new ASUS desktop with a 1TB HD loaded with Window$ 8. I plugged in my two linux drives (OS & home DIR) but the screen was black and nothing would show up, I removed them again and now Windows is starting up again. Any ideas?

lewashby 56 Junior Poster

Working! thanks all.

lewashby 56 Junior Poster

I see that I didn't past it here on daniweb but the last "}" is in my script and it still isn't doing anything.

lewashby 56 Junior Poster

I took a second look, I don't see any missing "}".

lewashby 56 Junior Poster

I did make sure that both fields were the same but I did that part with php. Thanks, I'll give this another try.

lewashby 56 Junior Poster

In the following code blocks I don't see any affect that my java scipt is having on my form. Any ideas? Thanks.

Form:

    if($row['password'] == $passwd)
    {
    echo "<html>";
    echo "<body>";
    echo "<script src='check.js'></script>";
    echo "<form id='form1' action='changepassword.php' method='post'>";
    echo "<table>";
    echo "<tr><td>";
    echo "New Password<center><input type='text' name='newpassword1'></td></tr></center>";
    echo "<tr><td>";
    echo "Re-Enter Password<center><input type='text' name='newpassword2'></td></tr></center>";
    echo "<tr><td><input type='submit' value='submit' onclick='return validate(this.form,6,8)'></td></tr>";
    echo "</table>";
    echo "</form>";
    echo "</body>";
    echo "</html>";
    }

Script:

function validate(form, minlength, maxlength) 
{
    var userInput = form.elements[0].value

if(userInput.length >= minlength && userInput.length <= maxlength)
{
    return true;
}
else
{
    alert("Please input between " + minlength + " and " + maxlength + " characters");
    return false;
}
lewashby 56 Junior Poster
if($row['password'] == $passwd)
        {
        echo "<html>";
        echo "<body>";
        echo "<script src='check.js'></script>";
        echo "<form id='form1' action='changepassword.php' method='post'>";
        echo "<table>";
        echo "<tr><td>";
        echo "New Password<center><input type='text' name='newpassword1'></td></tr></center>";
        echo "<tr><td>";
        echo "Re-Enter Password<center><input type='text' name='newpassword2'></td></tr></center>";
        echo "<tr><td><input type='submit' value='submit' onclick='return validate(this.form,6,8)'></td></tr>";
        echo "</table>";
        echo "</form>";
        echo "</body>";
        echo "</html>";
        }

What am I doing wrong?

function validate(form, minlength, maxlength) 
{
var userInput = form.elements[0].value

if(userInput.length >= minlength && userInput.length <= maxlength)
{
    return true;
}
else
{
    alert("Please input between " + minlength + " and " + maxlength + " characters");
return false;
}

}
lewashby 56 Junior Poster

echo "<tr><td><input type='submit' value='submit' onclick='stringlength(document.form1.text1,6,8)'></td></tr>";

& the file

function lengthRange(inputtxt, minlength, maxlength)  
{     
   var userInput = inputtxt.value;    
   if(userInput.length >= minlength && userInput.length <= maxlength)  
      {       
        return true;      
      }  
   else  
      {       
    alert("Please input between " +minlength+ " and " +maxlength+ " characters");         
        return false;     
      }    
}

Are not having any affect on my password input. Any idea?

lewashby 56 Junior Poster

http://www.w3resource.com/javascript/form/string-length.php

In the above link I see two different JS areas, Javascript function to restrict length of user input, & Javascript code. All I'm trying to do is validate that the users password of choice is at least x characters in length. Which one of these examples is what I'm looking for? Thanks.

lewashby 56 Junior Poster

delete hash from users where email='emailaddress@hotmail.com';

Why is the above line not working? I want to delete the value in the hash column in the row the contains the specified email.

lewashby 56 Junior Poster

I changed the code to the following but when this program runs it's still skipping this part.

//$userEmail = $db->query("SELECT email FROM users WHERE email='$email'");

//$userPsswd = $db->query("SELECT password FROM users WHERE email='$email'");

$row = $db->query("SELECT email, password FROM users WHERE email='$email'");
    $query = $row->fetchArray(SQLITE_NUM);
    $userEmail = $query[0];
    $userPsswd = $query[1];

Any ideas?

lewashby 56 Junior Poster

But userEmail and userPsswd or quried from a database and checked against the email and psswd form variables. How does your version know what the email and password from the database is?

lewashby 56 Junior Poster

In the following program can someone please tell me why my script is skipping the first else clause and never printing "You have already changed your password"? Everything else is working fine but when I enter in a username and password that have already been entered into the system it skips the portiong of code designed for that case. Thanks.

<?php

$email = $_POST['email'];
$psswd = $_POST['psswd'];

$db = new SQLite3('./users.db', SQLITE3_OPEN_READWRITE);

if(!$db)
{
    echo "Could not open/access DB";
}
else
{
    $userEmail = $db->query("SELECT email FROM users WHERE email='$email'");
    $userPsswd = $db->query("SELECT password FROM users WHERE email='$email'");

    if($email == $userEmail && $psswd == $userPsswd)
    {
        echo "You have already changed your password";
    }
    else
    {
        $file = fopen("./accounts.txt", 'r+') or die("Failed to open file");


        while(!feof($file))
        {
            $line = fgets($file);
            if(strpos($line, "$email") !== false)
            {
                echo "User was a match";
            if(strpos($line, "$psswd") !== false)
            {
            header("location: /ET/password/changepassword.html");
            break;
        }
        else
        {
            echo "Invalid password";
            break;
        }
        }
        else
        {
            echo "Invalid email address";
        break;
        }
    }
    }

    fclose($file);
}
?>
lewashby 56 Junior Poster
$userEmail = $db->query("SELECT email FROM users WHERE email='$email'");
$userPsswd = $db->query("SELECT password FROM users WHERE email='$email'");

Can someone tell me what I've done wrong in teh two lines above? I'm getting the following errors.

PHP Warning: SQLite3::query(): Unable to prepare statement: 1, near &quot;@hotmail&quot;: syntax error in /var/www/ET/password/accounts.php on line 14

PHP Warning: SQLite3::query(): Unable to prepare statement: 1, near &quot;@hotmail&quot;: syntax error in /var/www/ET/password/accounts.php on line 15

lewashby 56 Junior Poster

It's always the little things!

lewashby 56 Junior Poster

PHP Parse error: syntax error, unexpected end of file in /var/www/ET/password/changepassword.php on line 27

Can someone please tell me what I'm doing wrong in the following code to get the error above?

<?php

$db = new SQLite3('./users.db', SQLITE3_OPEN_READWRITE);

if(!$db)
{
        echo "Could not open/access DB";
}
else
{
    $userPsswd1 = $_POST['psswd1'];
    $userpsswd2 = $_POST['psswd2'];
    $email = $_POST['email'];

    if($userPsswd1 == $userPsswd2)
    {
        $db->exec("INSERT INTO users VALUES('$email', '$userPsswd1')");
        echo "Your password has been reset.";
    }
    else
    {
        echo "Your passwords do not match.";
    {
}

?>
lewashby 56 Junior Poster

In the following program the first strpos() function is working just just fine when searching for a matching email address in the text file as long as it's on the first line but the second entry it jumps streight to the else clause and echos "Unknown user name" even though that email is on line to of the file. Any ideas?

<?php

$email = $_POST['email'];
$psswd = $_POST['psswd'];

echo "The email address is $email<br>";
echo "The password is $psswd<br><br>";

$file = fopen("./accounts.txt", 'r+') or die("Failed to open file");

while(!feof($file))
{
    $line = fgets($file);
    if(strpos($line, "$email") !== false)
    {
        echo "There was a match";
    if(strpos($line, "$psswd") !== false)
    {
        echo "<br>Password is a match.";

        $db = new SQLite3('./users.db', SQLITE3_OPEN_READWRITE);
            if(!$db)
        {
        echo "Could not open/access DB";
        }
        else
        {
            echo "<br>DB is good!";
        }

        break;
    }
    else
    {
        echo "<br>Invalid Password!";
    }

    }
    else
    {
        echo "Unknown user name";
    //header("localhost/ET/password/:unknown.html");
    break;
    }

    //echo "$line<br>";
}
//$line = fgets(preg_match($email, '$file'));


fclose($file);

?>
lewashby 56 Junior Poster

I also got this error doing it that way.

[error] [client 127.0.0.1] PHP Notice: Array to string conversion in /var/www/ET/password/accounts.php on line 16

lewashby 56 Junior Poster

My program is stepping through the file line by line correctly, what I can't seem to be able to do is determine if the string supplied by the '$email' variable is a substring in the current line being processed.

lewashby 56 Junior Poster

(Linux)
In the following program I'm trying to process the file accounts.txt line by line searching for a match to the form supplied variable '$email'. The function fgets() is stepping though the file line by line correctly but my attempts at using preg_match() and or strpos() to determine if that line contains the string contained in '$email' have failed. Any ideas or suggestions? Thanks.

<?php

$email = $_POST['email'];
$psswd = $_POST['psswd'];

echo "The email address is $email<br>";
echo "The password is $psswd<br><br>";

$file = fopen("./accounts.txt", 'r+') or die("Failed to open file");

while(!feof($file))
{
    $line = fgets($file);
    if(preg_match($email, $line))
    {
        echo "There was a match";
    }
    else
    {
        echo "There was not match";
    }

    //echo "$line<br>";
}
//$line = fgets(preg_match($email, '$file'));


fclose($file);

?>
lewashby 56 Junior Poster

the www-data thing worked. Thanks.

lewashby 56 Junior Poster

(Linux)
In the following code all I'm trying to do is open a file but evertime I run this script the fopen function jumps right to the die() function. Any ideas? The file accounts.txt does exist in the same directory, and I also tried refrencing the file via ./accounts.txt .

<?php

$email = $_POST['email'];
$psswd = $_POST['psswd'];

echo "The email address is $email<br>";
echo "The password is $psswd<br>";

$file = fopen("accounts.txt", 'r+') or die("Failed to open file");

?>
lewashby 56 Junior Poster

Got it, thanks gusy.

lewashby 56 Junior Poster

Thanks guys, I'm a little closer but still not there yet. I chagned the insert line to this:

$db->exec("INSERT INTO customers VALUES(" .$fName . "," . $lName . "," . $email .")");

And now I'm getting this in the error log when I enter the name Bailey to be written into the fName field. The column name is

[Tue Sep 10 13:36:35 2013] [error] [client 127.0.0.1] PHP Warning: SQLite3::exec(): no such column: Bailey in /var/www/ET/insert.php on line 21, referer: http://localhost/ET/

lewashby 56 Junior Poster

This is the containing directory:
drwxr-xr-x 2 root root 4096 Sep 10 12:05 ET

Here is the file:
-rw-r--r-- 1 www-data root 2048 Aug 31 15:58 et.sqlite3
-rw-r--r-- 1 root root 410 Sep 10 10:35 insert.php

lewashby 56 Junior Poster

THX

lewashby 56 Junior Poster

In the following code the Submit button actualy says "Submit Query" on my page but I can not find anywhere that I have written "Submit Query" in the file. Any ideas? I would like to change the second one.

<html>
<head>
<title>Simiply Query</title>
<link rel="stylesheet" type="text/css" href="mystyles.css" media="screen" />
</head>

<body>

Query Database Form
<br><br>
<form action="process3.php" method="POST">
<div id="form1">
<table width="25%">

<tr> <td>First Name:</td> 
     <td align="right"> <input type="text" name="fname"></td></tr>

<tr> <td>Last Name:</td>
     <td align="right"> <input type="text" name="lname"></td></tr>

<tr> <td>Email:</td>
     <td align='right'> <input type="text" name="email"></td></tr>

    </select></td><td><input type="submit"></td></tr>
</table>
</form>

<br><br>
Insert Database Form
<br><br>
<form action="insert.php" method="POST">
<div id="form2">
<table width="25%">

<tr> <td>First Name:</td>
     <td align="right"> <input type="text" name="fname"></td></tr>

<tr> <td>Last Name:</td>
     <td align="right"> <input type="text" name="lname"></td></tr>

<tr> <td>Email:</td>
     <td align='right'> <input type="text" name="email"></td></tr>

        </select></td><td><input type="submit"></td></tr>
</form>
</table>
</div>
</body>
</html>
lewashby 56 Junior Poster

I'm getting this

-> [Tue Sep 10 10:42:46 2013] [error] [client 127.0.0.1] PHP Warning: SQLite3::exec(): unable to open database file in /var/www/ET/insert.php on line 21, referer: http://localhost/ET/

I changed the owner of the DB file (et.sqlite3) to www-data and now this is what I'm getting. Before I changed the owner I was getting an "unable to write to DB" error. Code is below, any ideas? Thanks.

<?php

echo "<html>";
echo "<head>";
echo "</head>";
echo "<body>";

$db = new SQLite3('./et.sqlite3', SQLITE3_OPEN_READWRITE);

if(!$db)
{
    echo "Could not open/access DB";
}
else
{
    // get variable from html form
    $fName = $_POST['fname'];
    $lName = $_POST['lname'];
    $email = $_POST['email'];

    $db->exec("INSERT INTO customers VALUES('$fName', '$lName', '$email')");
}

echo "</body>";
echo "</html>";

?>
lewashby 56 Junior Poster
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string.h>

int main(int argc, char *argv[])
{
    char string[13] = "";
    strcpy(string, argv[1]);

    while(strlen(string) % 3 != 0 || strlen(string) < 3)
    {
        int position = strlen(string);

        if(strlen(string) == 1)
        {
            for(int i = 0; i <= strlen(string); i++)
                    {
                            string[position + 1] = string[position];
                            position--;
                    }
        }

        for(int i = 0; i < strlen(string); i++)
        {
            string[position + 1] = string[position];
            position--;
        }

        string[0] = '0';
    }

    int groups = strlen(string) / 3;

    std::cout << string << std::endl;
    std::cout << groups << std::endl;

    return 0;
}
lewashby 56 Junior Poster

In the following small c++ program I'm trying to add '0' (zero characters) until the number of characters in the users input can be evenly divided by 3. I'v got it working except that it doesn't work when only on character is feed to the program.

input -> 123 -> nothing to change, good
input -> 1234 -> becomes "001234", good
input -> 12345 -> becomes "012345", good
input -> 12 -> becomes "012", good
input -> 1 -> get continues prompt, bad
input -> 5 -> get continues prompt, bad

Any idea on why this is happening?

#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string.h>

int main(int argc, char *argv[])
{
    char string[13] = "";
    strcpy(string, argv[1]);

    while(strlen(string) % 3 != 0 || strlen(string) < 3)
    {
        int position = strlen(string);
        for(int i = 0; i < strlen(string); i++)
        {
            string[position + 1] = string[position];
            position--;
        }

        string[0] = '0';
    }

    int groups = strlen(string) / 3;

    std::cout << string << std::endl;
    std::cout << groups << std::endl;

    return 0;
}
lewashby 56 Junior Poster

IIM thanks, your suggestion, it sort of worked but I want it to display all the columns in order in one line without all the technical mumbo jumbo '=>', just simply, I want it to print out "Fisrtname, LastName, EmailAddress"

string(7) "FirstName" Array ( [fname] => Firstname [lname] => LastName [email] => myEmailAddress )

pritaeas sorry, I post in more than one forum and sometimes forget that I already have a post in one forum or another.

lewashby 56 Junior Poster

I have a very small sqlite3 database with one row consisting of three columns but I can get the page to display the row to save my life. So far all I've been able to get the page to display is the first column of the one row that's in my DB using querySingle and echo $result. $entry doesn't seem to be doing anything neither does the bottomw while loop. Any ideas. All I want to do here is display the one row that's in my DB to the screen.

<?php
echo "<html>";
echo "<body>";
// get variable from html form
//$fName = $_POST['fname'];
//$lName = $_POST['lname'];
//$address = $_POST['email'];

$db = new SQLite3('./et.sqlite3', SQLITE3_OPEN_READWRITE);

if(!$db)
{
    echo "Could not open/access DB";
}
else
{
    echo "Database is here";
    //$result = $db->query('select * from customers');
    //var_dump($db->querySingle('select * from customers'));
    //print_r($db->querySingle('select * from customers', true));
    $result = $db->querySingle('select * from customers');
    echo $result;
    $query = sqlite_query($db, 'select * from customers');
    while($entry = sqlite_fetch_array($query, SQLITE_NUM))
    {
        echo $entry[0]." ".echo $entry[1]." ". echo $entry[2];
    }

    $i = 0;

    while($i < strlen($result))
    {
        echo $result[$i];
        $i++;
    }
}

echo "</body>";
echo "</html>";
?>
lewashby 56 Junior Poster

I can not get a page to load from the following php program. When I load the page in the browser all I get is a blank white page. I also looked in the /var/log/apache2/error.log file and found this line -> [Sun Aug 25 21:36:37 2013] [error] [client 127.0.0.1] PHP Fatal error: Call to undefined function sqlite_open() in /var/www/ET/process.php on line 9

Here's my code.

<?php
echo "<html>";
echo "<body>";
// get variable from html form
//$fName = $_POST['fname'];
//$lName = $_POST['lname'];
//$address = $_POST['email'];

$db = sqlite_open('./et', 0666, "$error_message");

//if($db == sqlite_open('./et'))
//{
//$result = sqlite_query($db, 'select * from customers');
//echo $result;
//}
echo "hello world!";
echo "</body>";
echo "</html>";
?>
lewashby 56 Junior Poster

I added the body tags, it hepled nothing. I didn't think that was it.

lewashby 56 Junior Poster

I've revised the code but it's still showing a blank page. And yes, et is the database.

<?php
echo "<html>";

// get variable from html form
$fName = $_POST['fname'];
$lName = $_POST['lname'];
$address = $_POST['email'];

if($db = sqlite_open('./et', 0666, "$error_message"))
{
$result = sqlite_query($db, 'select * from customers');
echo "$result";
}
echo "hello world!";
echo "</html>";
?>