lewashby 56 Junior Poster

I created a small table with one entrey with three columns but I can't get it to show up in my php code. I'm not really doing anything with the form variables right now I'm mainly focused on getting the code below that to query my SQLite DB.

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

$db = sqlite_open('./ET')
{
        $result = sqlite_query($db, 'select * from customers');
        echo $result;
}
?>
lewashby 56 Junior Poster

I think everything else is okay but I have just discovered that my if statement is executing no matter what. Can anyone tell me why?

if [[ "${#} -eq 8" ]]; then # {
    FREQUENCY=${6}
    OUTPUT=${7}
fi

I am running the program with only 6 command line arguments, well 7 if you count ${0} (the name of the script) but it's executing it anyway.

$ ./configure.sh ../system-2.4-BR.cfg MySSID newIP MyNano TheGate New-2.4-BR.cfg

lewashby 56 Junior Poster

Thanks, that might work. Since then I've altered just a little bit. Now I'm getting this when the script runs on a bridge configure file rather than an AP, where it doesn't use the frequency variable. ->

./configure.sh: line 16: ${OUTPUT}: ambiguous redirect

For this code. ->

#/bin/bash
#
# example: ./configure input-file, SSID, IP, device-name, gateway, frequency, output-file
#
FILE=${1}
SSID=${2}
IP=${3}
DEVICE=${4}
GATEWAY=${5}
FREQUENCY=""
OUTPUT=${7}

if [[ "${#} -eq 8" ]]; then # {
    FREQUENCY=${6}
fi
sed -e "s/\(empty-ssid\).*/${SSID}/g"      \
    -e "s/192\.168\.1\.20$/${IP}/g"        \
    -e "s/\(NanoBridge M.\)/${DEVICE}/g"   \
    -e "s/empty-frequency/${FREQUENCY}/g"  \
    -e "s/\(192\.168\.1\.1\).*/${GATEWAY}/g" ${FILE} > ${OUTPUT}
#END#

Any ideas now. I'm going to try your thing too.

lewashby 56 Junior Poster

kevinedwards are you saying the the software center is more powerfull than apt-get? If so, how so? I'm not assuming you're wrong, it's just that if you're right I would like to understand.

lewashby 56 Junior Poster

In the code below how do I get sed's find and replace value to cary over into the output that gets redirected to the .txt file at the end? Everything else gets replaced but everything in the if statement gets left behind.

# example: ./configure input-file, SSID, IP, device-name, gateway, frequency
#
#
FILE=${1}
SSID=${2}
IP=${3}
DEVICE=${4}
GATEWAY=${5}

if [[ ${#} == 5 ]]; then # {
        FREQUENCY=${6}
        sed -e "s/\(empty-frequency\)/${FREQUENCY}/g" 
fi 
sed -e "s/\(empty-ssid\).*/${SSID}/g"                   \
    -e "s/192\.168\.1\.20$/${IP}/g"                     \
    -e "s/\(NanoBridge M.\)/${DEVICE}/g"                \
    -e "s/\(192\.168\.1\.1\).*/${GATEWAY}/g" ${FILE} > /home/garrett/Desktop/NEW-CONFIG.txt
#END#
lewashby 56 Junior Poster

In the script below second & third line are working but not the first and fourth. The reason is because I am replacing the whole line, I actually only need to replace what's to the right of the '=' sign. Any idea on how I can accomplish this in sed? Thanks.

# example: ./configure input-file, SSID, IP, device-name, gateway, frequency
#
#
FILE=${1}
SSID=${2}
IP=${3}
DEVICE=${4}
GATEWAY=${5}

sed -e "s/\(wireless\.1\.ssid=\).*/${SSID}/g"           \
    -e "s/192\.168\.1\.20$/${IP}/g"                     \
    -e "s/\(NanoBridge M.\)/${DEVICE}/g"                \
    -e "s/\(route\.1\.gateway=\).*/${GATEWAY}/g" ${FILE} > /home/garrett/Desktop/NEW-CONFIG.txt
#END#
lewashby 56 Junior Poster

Yea, thanks. Now it's actually replacing the text the the strings "${SSID}", "${DEVICE}", etc. Any further input?

lewashby 56 Junior Poster

How hard would it be to convert the project from the link I gave above to SQLite?

lewashby 56 Junior Poster

I removed the /g and I got the same thing.

lewashby 56 Junior Poster

In the following code I'm trying to figure out what InitDB is? I need to reconfigure these files for a particular website and to use SQLite. http://www.html-form-guide.com/php-form/php-registration-form.html

<?PHP
require_once("./include/fg_membersite.php");

$fgmembersite = new FGMembersite();

//Provide your site name here
$fgmembersite->SetWebsiteName('user11.com');

//Provide the email address where you want to get notifications
$fgmembersite->SetAdminEmail('user11@user11.com');

//Provide your database login details here:
//hostname, user name, password, database name and table name
//note that the script will create the table (for example, fgusers in this case)
//by itself on submitting register.php for the first time
$fgmembersite->InitDB(/*hostname*/'localhost',
                      /*username*/'prasanth',
                      /*password*/'p',
                      /*database name*/'testdb',
                      /*table name*/'fgusers3');

//For better security. Get a random string from this link: http://tinyurl.com/randstr
// and put it here
$fgmembersite->SetRandomKey('qSRcVS6DrTzrPvr');

?>
lewashby 56 Junior Poster

I'm getting sed: -e expression #1, char 35: unterminated s' command when I try and run the following script. Any ideas?

#/bin/bash
#
#
# This script is to be used to re-write a configuration file
# replacing select values, SSID, IP, device name, gateway,
# and frequency with the supplied command line arguments.
#
# example: ./configure input-file, SSID, IP, device-name, gateway, frequency
#
#
FILE=${1}
SSID=${2}
IP=${3}
DEVICE=${4}
GATEWAY=${5}

sed -e 's/\(wireless\.1\.ssid=\).*/\${SSID}'             \
    -e 's/192\.168\.1\.20$/${IP}/g'                      \
    -e 's/\(NanoBridge M.\)/\${DEVICE}/g'                \
    -e 's/\(route\.1\.gateway=\).*/\${GATEWAY}/g' ${FILE} > /home/garrett/Desktop/NEW-CONFIG.txt
#END#
lewashby 56 Junior Poster

I think I had the wrong one installed. Fixed now, thanks guys.

lewashby 56 Junior Poster

(Linux System) Everytime I try to log into MySQL or create a database I get "Access denied for user@localhost". I just recently installed mysql using apt-get install and I don't recal creating a password or anything for it when I installed it. Any ideas?

lewashby 56 Junior Poster

Got it.

lewashby 56 Junior Poster

In the following script I need to know if the configuration files is for a 2.4 or a 5.2 radio. This info is found in the filename so I'm trying to use grep -l 2.4 to find out if it's a 2.4 config file or not. If it's not the script sould go to the else clause but it's still echoing "5.2" file even when the file used as the command line argument is a 2.4 file.

garrett@bedroom ~$ ./testScript.sh system-2.4-AP.cfg
M2
M5
5.2 file
system-2.4-AP.cfg
empty-ssid
NanoBridge

Here's the script

FILE=${1}
SSID=$(grep -o empty-ssid ${FILE})
GATEWAY=$(grep -o 192.168.1.1 ${FILE})
#IP=$(grep -o ###.###.###.### ${FILE})
DEVICE="NanoBridge"

M2=" M2"
M5=" M5"

echo ${M2}
echo ${M5}

if [ $(ls ${FILE} | grep -l *2.4*) ]; then #{
        DEVICE=${DEVICE}${M2}
        echo "2.4 file"
else #} {
        #DEVICE="${DEVICE}${M5}
        echo "5.2 file"
fi #}

echo ${FILE}
echo ${SSID}
#echo ${FILE:${#FILE} - 2}
echo ${DEVICE}
#END#

Any ideas?

lewashby 56 Junior Poster

garrett@bedroom ~/Desktop/folder/project $ ./testScript.sh OLD-172.28.50.30-system.cfg

Above is what I'm getting now. It's returning $FILE but not $SSID.

Here's what the line looks like now ->

SSID=$(grep -o empty-ssid ${FILE})

lewashby 56 Junior Poster

empty-ssid is not a file, it's a line of text inside a file. I thought using the backtick was teh same as using $() ?

lewashby 56 Junior Poster

I How can I get the output from grep into a variable? In the following program I've tried the SSID line two ways but I am not getting what I want.

SSID=$(grep) ${FILE} -o empty-ssid
Gives me this

garrett@bedroom ~/Desktop/folder/project $ ./testScript.sh ../OLD-172.28.50.30-system.cfg 
Usage: grep [OPTION]... PATTERN [FILE]...
Try 'grep --help' for more information.
./testScript.sh: line 5: ../OLD-172.28.50.30-system.cfg: Permission denied
../OLD-172.28.50.30-system.cfg

SSID=$(grep ${FILE} -o empty-ssid)
Gives me this

garrett@bedroom ~/Desktop/folder/project $ ./testScript.sh ../OLD-172.28.50.30-system.cfg 
grep: empty-ssid: No such file or directory
../OLD-172.28.50.30-system.cfg

Program

FILE=${1}
SSID=$(grep) ${FILE} -o empty-ssid

echo ${FILE}
echo ${SSID}
#END#
lewashby 56 Junior Poster

Thanks TheApex that got it.

lewashby 56 Junior Poster

In the following program everything works fine when I enter 5 or 8, but if I enter 4 or 7 the program crashes with a Segmentation fault error. I'm just trying to add zeros until the number of characters in string is evenly divisible by 3 and I'm doing so by padding it with zeros.

garrett@bedroom ~/Projects/TestArea $ ./addZeros 12345
12345
012345
garrett@bedroom ~/Projects/TestArea $ ./addZeros 1234
1234
Segmentation fault

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

int main(int argc, char *argv[])
{
    char string[10] = "";
    strcpy(string, argv[1]);
    std::cout << string << std::endl;



    int position = strlen(string);


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

        }

        string[0] = '0';
    }

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

    return 0;
}
lewashby 56 Junior Poster

I'm intrested mainly in getting the skills needed to get job in the I.T. field. JorgeM, I know just enough HTML & CSS to get by. The problem is HTML bores me to death.

lewashby 56 Junior Poster

Any ideas on some good beginner projects for PHP? I'd like to at, some point in the future, get into front end development and although I have a little self taught programming knowledge I don't have any real work experience in I.T. or programming at all, just the programs you write following python & c++ books of the shelf.

lewashby 56 Junior Poster

Any idea why this is happening?

garrett@bedroom ~ $ mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
lewashby 56 Junior Poster

Using Linux. I'm trying to learn PHP so I'm also going to need to learn some MySQL to work with my PHP code. Do I need mysql client or mysql server? I thought it was on my system but after issuing the command 'mysql' I got the following error.

garrett@bedroom ~ $ mysql
The program 'mysql' is currently not installed. You can install it by typing:
sudo apt-get install mysql-client-core-5.5
lewashby 56 Junior Poster

Thanks rubberman.

lewashby 56 Junior Poster

But I set same error when I change the line from Tkinter import * to from tkinter import *

lewashby 56 Junior Poster

I know there are tools than can take DRM off of audio files but I haven't found any that will take DRM off of .aax files.

Danies Joe commented: I guess I fond one that works well. It's called TuneFab Apple Music Converter which can take DRM off Apple Music and Audible audiobook. +0
lewashby 56 Junior Poster

(Linux) In the following program when the command python permissions.ph is issued I simply get another prompt, but when python3 permissions.py is issued I get the error below. Why does python2 see tkinter but python 3 doesn't?

garrett@bedroom ~/Projects/TestArea $ python permissions.py 
garrett@bedroom ~/Projects/TestArea $ python3 permissions.py 
Traceback (most recent call last):
  File "permissions.py", line 1, in <module>
    from Tkinter import *
ImportError: No module named 'Tkinter'
garrett@bedroom ~/Projects/TestArea $ 






from Tkinter import *
def fileopenbox(msg=None, title=None, default=None):
    root = Tk()
    root.withdraw()
    f = tkFileDialog.askopenfilename(parent=root,title=title, initialfile=default)
    if not f: return None
    return os.path.normpath(f)
lewashby 56 Junior Poster

I use Linux & Rhythmbox to manage my iPod but that is blocking me from being able to use the .aax audio book file from audible.com The .aax files work well with iTunes but since I don't use iTunes anymore I'm kinda out of luck. I could manually place the .aax files into my iPod but I don't know where I should place them for them to work or even if that would make them show up on my iPod. Any ideas on where .aax file from audible.com need to be placed in the iPod and or does this work?

lewashby 56 Junior Poster

vegaseat What do you mean?

lewashby 56 Junior Poster

james.lu.75491856 What if I want all the permissions just as they're listed using ls -l?

lrwxr--r--
drwxr-w---

lewashby 56 Junior Poster

How could I get the file name and the permissions to a file as a string? This is on a Linux system.

lewashby 56 Junior Poster

I'm using LinuxMint 15.

I'm getting the following errors when I tried to install the AMD CATALYS 13.1 Legacy driver. Any ideas what's wrong and what I can do?

garrett@garrett-bedroom ~ $ cat /usr/share/ati/fglrx-install.log 
Detected a previous installation, /usr/share/ati/amd-uninstall.sh
Dryrun uninstall succeeded continuing with installation.
Check if system has the tools required for installation.
Uninstalling any previously installed drivers.
Forcing uninstall of AMD Catalyst(TM) Proprietary Driver.
No integrity verification is done.
restore of system environment completed
Errors during DKMS module removal
Uninstall fglrx driver complete.
For detailed log of uninstall, please see /etc/ati/fglrx-uninstall.log
System must be rebooted to avoid system instability and potential data loss.
/usr/share/ati/amd-uninstall.sh completed with 0

Creating symlink /var/lib/dkms/fglrx/8.97.100.7/source ->
                 /usr/src/fglrx-8.97.100.7

DKMS: add completed.

Kernel preparation unnecessary for this kernel.  Skipping...

Building module:
cleaning build area....
cd /var/lib/dkms/fglrx/8.97.100.7/build; sh make.sh --nohints --uname_r=3.8.0-19-generic --norootcheck....(bad exit status: 1)
[Error] Kernel Module : Failed to build fglrx-8.97.100.7 with DKMS
[Error] Kernel Module : Removing fglrx-8.97.100.7 from DKMS

------------------------------
Deleting module version: 8.97.100.7
completely from the DKMS tree.
------------------------------
Done.
[Reboot] Kernel Module : update-initramfs
lewashby 56 Junior Poster

rch1231, thanks for you detailed response. What I actually ended up doing to get it to work was simply placing #!/bin/bash at the top and making it executable.

lewashby 56 Junior Poster

Thanks snippsat.

rubberman, I posted two links showing that I did in fact attempt to RTFM!

lewashby 56 Junior Poster

I'm looking throug the documentation at python.org for modules and functions allow me to do basic operations on in a Linux file system. I need to do simple things like list the file and folders in a directory 'ls' and change director 'cd'. I found these two pages that looked promesing but I still didn't fine what I was looking for. Any ideas?

http://docs.python.org/3/library/shutil.html#directory-and-files-operations

http://docs.python.org/3/library/os.path.html

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

if(str.isdigit(sys.argv[1]) == True):
    number = sys.argv[1]
    print(number)
    #print(number.count(str(number)))
    print(len(str(number)))
else:
    print("Input was not a number ", "formate as -> ", sys.argv[0], " 123")
lewashby 56 Junior Poster

Okay, I exited the code and it's no longer giving me an error but it is giving me output that doesn't make sence to me. It's printing "1" for the line print(number.count(str(number))) when has far as I can tell it should be printing 3.

garrett@garrett-bedroom ~/Projects/Enrique/NumbersToStrings/python $ ./NumbersToStrings.py 123
123
1

What I'm trying to do here is get the count the number of characters in number.

Here's the new code.

#!/usr/bin/python3
import sys

if(str.isdigit(sys.argv[1]) == True):
    number = sys.argv[1]
    print(number)
    print(number.count(str(number)))
else:
    print("Input was not a number ", "formate as -> ", sys.argv[0], " 123")
lewashby 56 Junior Poster

print(str.count(str(number))) So how would I get this line done. when I write it as

print(str.count(number)) I get the same result.

lewashby 56 Junior Poster

In the following program, why is the count function failing? I'M getting an error that it needs at leat one argument and that I have given it 0. I have here count(number), how is number no an argument? According to the documentation the start and end points are optional. I figured that just giving one argument, the whole string, would give me the count on the whole thing by default and thats what the documentation suggested to me.

#!/usr/bin/python3
import sys

while(str.isdigit(sys.argv[1]) == True):
    number = sys.argv[1]
    print(number)
    print(str.count(str(number)))
    exit

print("Input was not a number ", "formate as this -> ", sys.argv[0], " 123")
lewashby 56 Junior Poster

Linux Mint 15

I'm trying to run this small script located in /etc/cron.hourly/ in order to learn how to use cron but it's not running, any ideas? And the "test" script in this case has already been set to executable.

garrett@garrett-bedroom /etc/cron.hourly $ cat test
touch /home/garrett/Desktop/CRONTABWORKED!.txt
#ENE#
lewashby 56 Junior Poster

Thanks mike. I did research all the options including default but after reading it's description I wasn't sure about it either. But I tried it and it worked fine. Thanks again.

lewashby 56 Junior Poster

If I wanted to host a game on let's say, Steam Counter-Strike, what setting to I need t use for port forwarding to let someone I know login using my routers IP address. I options are TCP/UDP, TCP, & UDP. Also, what should be my starting and ending ports? Thanks.

lewashby 56 Junior Poster

Please take a look at my fstab below. I'm trying to mount the HD stb onto /home/garrett/ but I don't know waht options I should choolse. Thanks for any and all replies.

# /etc/fstab: static file system information.
#
# <file system> <mount point>   <type>  <options>                                       <dump>  <pass>
proc    /proc   proc                    defaults                                        0       0
# /dev/sda1
UUID=6ad5c578-f3ba-4228-885f-ae74e9e81ba9       /       ext4    rw,errors=remount-ro    0       1
# /dev/sda5
UUID=0076c4a3-e29d-49bb-8f3a-a28d5ecac482       swap    swap    sw                      0       0
# /dev/sdb
#UUID=86e3838b-7c18-4870-8a7b-684255629264      /home/garrett/  ext4 <options>          0       2
lewashby 56 Junior Poster

All your link does is take me to the top of the page.

lewashby 56 Junior Poster

I need to make a script run under my username each time the computer boots up. I have been told that the file I need is in the /etc/init.d/ directory but that's all I know. This script will not be service I shouldn't have to mess with all the 'S' , 'K', & rc crap. Any ideas?

lewashby 56 Junior Poster

I'M trying to get my .aax audio book file from my computer to my iPod but am having trouble. I don't use iTunes or Microshaft Window$ so it's a little more complicated. I'M using the Linux OS with Rhythmbox media player. I tried to manually move my .aax files to the iPod via drag and drop but the books still did not show up under > Music > Audiobooks. Any ideas how I can get them to show up manually placing the files onto the iPod device?

iPod classic 120 Gig

lewashby 56 Junior Poster

Thanks mike. That worked, I just don't understand how or why. How does supctracting the char '0' from the ASCII value of [0] which is 48 if [0] is 1 get me the input value?

lewashby 56 Junior Poster

In the following program I'm trying to set the first, second, & third character values stored in processTheseThree [0], [1], & [2] to the int values D1, D2, & D3. When I tested my code with the line
std::cout << processTheseThree[firstSecondThird] << std::endl; I was getting the correct values but when I try to assign those values to my D3 int variables I'M getting really hight number like 48-51, even when I only input 123. Also, don't worry about the recourses.h file, it just hold an array of strings that I'm not currently using.

#include <iostream>
#include <stdlib.h>
#include <string.h>
#include "resources.h"

int main(int argc, char *argv[])
{
    char inputNumber[25] = "000000000000";
    strcat(inputNumber, argv[1]);

std::cout << inputNumber << std::endl;

    char *input = inputNumber + strlen(inputNumber) - 12;

std::cout << input << std::endl;

    int groups = 4;
    char processTheseThree[4] = "";
    char *theCharIncrementer = input + 9;

    int firstSecondThird = 0;
    while(groups > 0)
    {
        strncpy(processTheseThree, theCharIncrementer, 3);
//      processTheseThree[theCharIncrementer + 4] = '\0';
        //processTheseThree[3] = '\0';
        //std::cout << processTheseThree << std::endl;

        //while(firstSecondThird < 3)
        //{
            //std::cout << processTheseThree[firstSecondThird] << std::endl;
            int D1 = (int)processTheseThree[0];
            int D2 = (int)processTheseThree[1];
            int D3 = (int)processTheseThree[2];

            std::cout << D1 << std::endl << D2 << std::endl << D3 << std::endl;

            //firstSecondThird++;
        //}

        theCharIncrementer -= 3;
        groups--;
    }


    return 0;
}
/*END*/
lewashby 56 Junior Poster

Thanks guys. Got it working.