lewashby 56 Junior Poster

echo ${NUM:0:2}

The above is just an example of the kind of code I'M using. I need a way to represent the end of the string. Is there a way to start from the right side of a line of text instead of the left? What I'M trying to do here is grab the last three digits on end, then the next three and so on. NUM in this case will be a user input so there is no way to hard code the end position. Thanks.

lewashby 56 Junior Poster

The following line of code should result in GROUPS holding a number from 1 to probably 4 or 5. I need the next line to simply add 1 to whatever this lines results to. I've tried a lot of tings in bash but I can't make it happen. Any ideas? Thanks. GROUPS=$( expr ${NUMBEROFDIGITS} / 3 )

I thought it would be as simple as ${GROUPS}=${GROUPS+1} or }+1 but nothing I've tried has worked.

lewashby 56 Junior Poster

You saying that my question on indexing an array was really awesome? What?

lewashby 56 Junior Poster

I've got an array CALENDER=(31 28 31 30 31 30 31 31 30 31 30 31)

I have two if statements that Need to get an index from the array above but when I feed a value into the brackets e.g. ${CALENDER[${SECONDDIGIT}]} or ${CALENDER[${FIRSTDIGIT}]} it seems to only be getting the first inded of the CALENDER array, 31, even though FIRSTVALUE will have a number from 1-9 in it and SECONDDIGIT will have 10, 11, or 12. Any ideas by I am unable to get the correct index with my FIRST and SECONDDIGIT values? Thanks.

lewashby 56 Junior Poster

Thanks. I did fix that one. For whatever reason the program is running the get_day function that's in the else clause even when result == true.

lewashby 56 Junior Poster

I wrote the following script to try and get validate if a date was valid or not. I think I've about got the script done but I'M having some trouble getting the values from the array. When I input 11291985 into the program I'M getting "29 is invalid" I can't figure out where my logic or syntax is wrong here. All this program is doing is making sure that the month is > 0 & < 13, making sure the year is > 0, then if the months is 2 it checks to see if the year is leap year. If it is leap year the program make sure the day value in the number is > 0 & <=29. If it is not leaop year it runs a function that checks the day against an array containing the maximum number of days for each month. If the day is > 0 and <= the number of days for that month the all is well, otherwise you need to get invalid date. I'M getting invalid date even when supplying it valid dates.

#! /bin/bash -x


#############################
### FUNCTION-is_leap_year ###
#############################

is_leap_year()
{
        PART1=`expr ${YY} % 4`
        PART2=`expr ${YY} % 100`
        if [[ 0 -eq ${PART1} ]] && [[ 0 -ne ${PART2} ]] || [[ 0 -eq `expr ${YY} % 400` ]]; then
                result=true

        else
                result=false
        fi
}



####################
### END FUNCTION ###
####################

########################
### FUNCTION-get_day ###
########################

get_day()
{
    DAY="BAD"
    if [[ ${DD} -gt 0 ]] && [[ …
lewashby 56 Junior Poster

garrett@ubuntu-laptop:/etc$ ls -l vim*
total 8
-rw-r--r-- 1 root root 2215 Aug 29 16:23 vimrc
-rw-r--r-- 1 root root 662 Aug 29 16:43 vimrc.tiny
garrett@ubuntu-laptop:/etc$ cat vimrc
cat: vimrc: No such file or directory
garrett@ubuntu-laptop:/etc$

Could someone please explain how the abbove is possible? How is vimrc showing up as a file but when I try and cat it I get No such file or directory. I can also do "vi vimrc" and I get a blank page as if I were creating a new file rather than editing an existing one.

lewashby 56 Junior Poster

I'M trying to test a function that would be able to determine if it was or was not leap year. I believe my problem lies in the if statement but due to my lack of knowledge concerning shell I don't know what else to do here.

#! /bin/bash

read -p "Enter year" YY


leap_year()
{
    if [ (expr 0 -eq (${YY} % 4)) ] && [ (expr 0 -ne (${YY} % 100)) ]; then
        echo "Leap Year"

    else
        echo "Not leap Year"
    fi
}

leap_year $YY
lewashby 56 Junior Poster

Below is a program I'M trying to write that will take an 8 digit date and validate whether or not it's a valid date. I'M very new to shell scripting so I really a have no idea what I'M going. Could you take a look and let me know what all I'M doing wrong here? Thanks.

#! /bin/bash -x

# This is the calender array for the DateValidation program
CALENDER=(31 28 31 30 31 30 31 31 30 31 30 31)

read -p "Enter a date for validation: " DATE

# establish the varible LEN to hold the number of characters in Date, 8 is the only valid number
LEN=$(echo ${#DATE})

if [ $LEN -eq 8 ]; then #{

    # set date dariables MM, DD, & YY
    export MM=${DATE:0:2}
    export DD=${DATE:2:2}
    export YY=${DATE:4:4}

    if [ ${YY} -gt 0 ]; then #{
        if [ ${MM} -gt 0 & < 13 ]; then #{
            if [ ${MM} -eq 2 ]; then #{
                if [ is_leap_year ${YY} == 1 ]; then #{
                    if [ ${DD} -gt 0 & -le 29 ]; then #{
            elif [ ${DATE} -gt 0 & -le ${CALENDER[${MM}]}] #}}}}}}

    echo "${DATE} is a valid date"
else
    "${DATE} is an invalid date"
fi #}

#############################
### FUNCTION-is_leap_year ###
#############################

is_leap_year() {

if [ 0 -eg ${YY} % 4 & 0 -ne {YY} % 100 or 0 -eq ${YY} % 400 ]; then #{

    return true #}
else #{
    return false #}

exit
#END
lewashby 56 Junior Poster

I'M trying to write a small program that will validate weather or not a string is valid. Assuming that the date will always be 8 digits (12/21/2012) I need a function that will count the number of digits in a string. What I've got below is only returning "'is not 8 digits' even when I am inputing 8 digits.

! /bin/bash
This is the calender array for the DateValidation program

calender=(31 28 31 30 31 30 31 31 30 31 30 31)

read -p "Enter a date for validation: " Date

set the variable "LEN" to hold the lengh of the input number

LEN=$(echo ${Date})

if [ $LEN -lt 8 ]; then

echo "$Date' is 8 characters'"

else "$Date' is not 8 characters'"

fi

END
lewashby 56 Junior Poster

WD-TV-Live4Permissions4network16network23 I have Western Digital TV Live that plugs into my TV and also into my 1TB external HD. I have attached four pictures to help with what I'M confused and having trouble with. Take a look at my network1.png, notice that the device is listed in two places, one big icon in the right area and one small icon listed to the lower left havigation panel. When I lick on the big WDTVLive icon in the right area I get the web page you see in WD-TV-Live.png but when I click the one to the lower left I get what you see in network2.png, it's let's me right in without a poblem. How can one icon a secure and want a password(that by the way I don't remember ever creating for the WD device or my external 1TB HD) and the other icon let me right in? And since anyone can navigate right in using the icon listed on the left navigation panel of windows exporer, anyone in the house could potentially delete the movies, not just watch them. So I decided to plug the 1TB drive into my computer and set permissions so that noone else could have write permissions, only read. Now I'M more use to Linux permissions rwx for user, group, and other/everyone else. So I don't really know what I"M doing. Please take a look at Permissions.png and tell …

lewashby 56 Junior Poster

Below is a short program I'M working of from udacity.com but I can't figure out why I'M getting the value 6 from the first call to the function.

# Define a procedure, biggest, that takes three
# numbers as inputs and returns the largest of
# those three numbers.

def biggest(first, second, third):
    if (first > second and third):
        return first
    if (second > first and third):
        return second
    else:
        return third




print biggest(3, 6, 9)
#>>> 9

print biggest(6, 9, 3)
#>>> 9

print biggest(9, 3, 6)
#>>> 9

print biggest(3, 3, 9)
#>>> 9

print biggest(9, 3, 9)
#>>> 9
lewashby 56 Junior Poster

I'M trying to create a flowchart for a simple program that would take a number (1, 16, (100,100,000), or pretty much whatever you can think of and return it as a sting. For example, input -> 100,100,100 return -> one hundred million one hundred thousand one hundred. I've attached my dia digram could you please take a look and let me know how it looks.

Nevermind, it's not going to let me upload my files, even as JPGs.

lewashby 56 Junior Poster

Ah, that makes sence. Thanks. Didn't even think to look there.

lewashby 56 Junior Poster

Why is PHP not in the Software Development list?

lewashby 56 Junior Poster

I've got a guy that has been kind enfough to start teaching me Linux administration and programming. I want's me to write a pseudocode program to take any numberand print it out as a string. I'M woing to attached my pdf version and read below to see his email. I am not looking for you to give me the answere here but I just don't kwnow what else he wants.

Do you remember how we tested the 'validate date' program?
We got a date, 'fed it' to 'the program' (ran it on paper) and we got a
REAL result that stated 'valid' or 'invalid'

Please feed the number: 100,100,100.00
to your 'program' and show me, following ONLY the directions in your paper,
how it turns into:
One hundred million, one hundred thousand, one hundred and 00 cents.

I will need to be able to feed my own numbers and get my own results without
your assistance.
If I can't cook my own pancake following your cookbook without calling you,
then your cookbook is wrong and/or incomplete.
ET

PS: You will probably need to place you instructions in 'flow chart' symbols
to make it understandable.

lewashby 56 Junior Poster

I'M about to wipe out my installtion of MintLinux and I need to back up my firefox and google chrome favorites. Does anyone know where these files are kept? Thanks.

lewashby 56 Junior Poster
import wx

app = wx.App()
win = wx.Frame(None)
win.Show()
app.MainLoop()

Why does the above code only work in python2.7 and not 3?

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

print('Content-type: text/plain')
# prints an empty line, to end the headers

print('Hello, world!')

I'M trying to get the above python cgi output to load in my web browser but the browser is just displaying the code it's self. My apache program is working because I just tried the phpinfo function and it worked just fine. I'M getting this code from a book and it's actually showing #!/usr/bin/env python but I decided to use what I got with the which command "which python3" -> /usr/bin/python3

lewashby 56 Junior Poster

Guys pleas read the following page and don't forget to drop them a really positive email that's given at the bottom of the website. Thanks. Let them know you're willing to buy the product again if necessary to have a native Linux copy of your favorite valve game. Thanks

http://blogs.valvesoftware.com/linux/

lewashby 56 Junior Poster

Just got the book C++ Programming in easy steps. I just did the following program and although I ran it with now problems the book and this program really do not at all help understand how an enum or a typedef are usefull in the real world.

#include <iostream>
using namespace std;

int main()
{
    const double PI = 3.1315926536;
    cout<< "6\" circle circumference: " << (PI * 6) << endl;

    enum
    {RED=1, YELLOW, GREEN, BROWN, BLUE, PINK, BLACK };
    cout<< "I shot a red worth: " << RED << endl;
    cout<< "Then a blue worth: " << BLUE << endl;
    cout<< "Total scored: " << ( RED + BLUE ) << endl;

    typedef enum {NEGATIVE, POSITIVE} charge;
    charge neutral = NEGATIVE, live = POSITIVE;
    cout<< "Neutral wire: " << neutral << endl;
    cout<< "Live wire: " << live << endl;

    return 0;
}
lewashby 56 Junior Poster
garrett@mint-desktop ~ $ c++ -v
Using built-in specs.
COLLECT_GCC=c++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.6/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.6.3-1ubuntu5' --with-bugurl=file:///usr/share/doc/gcc-4.6/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.6 --enable-shared --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.6 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin --enable-objc-gc --disable-werror --with-arch-32=i686 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5) 

Do I have the GNU C++ compiler? If so how do I launch it? If not how do I get it?

lewashby 56 Junior Poster
( make 2>&1 | tee make.log && exit $PIPESTATUS ) &&

Could someone give me a detailed explanation of the above line? I know that tee is creating a text file while also allawing the output to come to the screen but need a better understanding of $PIPESTATUS. Is "exit" exiting everything to the left of it or $PIPESTATUS to the right? Why are there two sets of "&&"? And I'M sure the variable $? comes it to play somewhere here. Thanks.

lewashby 56 Junior Poster

Why does spell checking not work in the text fields here at daniweb? It works in the title but not here in the actual post. I'M a really bad speller so this is really frustrating.

lewashby 56 Junior Poster

I have been instructed by my instructor to write a pseudocode date program. The program need to accept a date by looking at the year, then the month, and the day as well as to account for leap year. Please do not hesitate to help me out here, it's a private instructor, tutor, mentor, what have you, not a standard school and he's doing it for free. Any way, take a look below to see what I first wrote.

Table A = Month/day table Common year
Table B = Month/day table Leap Year

Is the year received a positive number greater than 0? If yes continue, if No wait for a valid number.

Is the month a positive number that is less than 13? if Yes continue, If No wait for a valid number.
Get leap year

Is the year leap year?

Is the remainder of the year divided by 400 0? If Yes leap year = true
Is the remainder of the year divided by 100 0? If Yes leap year = false
Is the remainder of the year divided by 4 is 0?  If Yes leap year = true
otherwise leap year = false


If leap year, does the day match the corresponding value of the month in table B? If yes continue, If No wait for valid number.

If not leap year, does day match the corresponding value of the month in table A? If yes continue, If No wait for valid number.

Here's what he …

lewashby 56 Junior Poster

Thanks but I'M still looking to get a phone and a mp3 player in one device. What a good android phone that will work well with Linux?

lewashby 56 Junior Poster

I have a Samsung Galaxy Tab. To my dissapointment it is unable to be mounted to Linux. I found a few website with instructions on how to mount it be so far they haven't worked. I'M really trying to get more and more away from Window$ but I'M finding it difficult. I've had bad luck running my iPod with every media player avaiable on Linux. So I was considering getting a new Samsung mp3 player but of course I'll have the same problem I'M having with my Tab. And as I understand it Android is Linux or Unix bases, how can this be? Though I don't have a a big interest in a smart phone I do like that idea of have my mp3 player and phone in one device. So my real question is what are the best mp3 players or smart phones on the market that work well with Linux and Nautilus?

lewashby 56 Junior Poster

I'M tring to install a bitcoin program and I'M told I need the following package:

garrett@toshiba-laptop ~ $ sudo apt-get install libssl-dev libdb4.8++-dev
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Package libdb4.8++-dev is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

Any ideas?

lewashby 56 Junior Poster

I'M using Mint Linux. Does anyone know where or how I could download a music store plugin for Rhythmbox? Please don't mention Banshee it refuses to sync to my iPod. I don't really like the idea of having to open Banshee just to purchase music.

I think Clementine has the wort interface I've ever seen.

lewashby 56 Junior Poster

I need to write a script to where the lower half does not execute until the current shell runs an exit or logout command. How can I do this? The script I need this on is below.

mount -v --bind /dev $LFS/dev        &&
mount -vt devpts devpts $LFS/dev/pts &&
mount -vt proc proc $LFS/proc        &&
mount -vt sysfs sysfs $LFS/sys       &&
chroot "$LFS" /tools/bin/env -i \
    HOME=/root                  \
    TERM="$TERM"                \
    PS1='\u:\w\$ '              \
    PATH=/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin \
    /tools/bin/bash --login +h

#logout
#umount -v $LFS/dev/pts
#umount -v $LFS/dev/shm
#umount -v $LFS/dev
#umount -v $LFS/proc
#umount -v $LFS/sys
lewashby 56 Junior Poster

I'M not a big game player but there are a few select games I have to keep Window$ around for (Half-Life original). I've also had bad luck replacing iTunes and running my iPod with Linux software.

lewashby 56 Junior Poster

I need to view a text file that located somewhere in a file.tar.bz2 file. Anyway I can explor a tar.bz2 file and view a text document there in?

lewashby 56 Junior Poster

I don't understand the second two line you listed but I did all three of them anyway. I still wasn't able to create my file within Nautilis and my DE. I ended up just chown of /var/www to garrett. I know that's probably not the safest way the only people on my network are in my house. Anyway.

lewashby 56 Junior Poster

One more thing. I'M doing this from Mint Linux and I'M having a little trouble in the /var/www directory. I thing is I don't have permission to edit in that directory so I'M having to, open the terminal in that directory and issue sudo touch filename.php and edit it via VI, again with sudo. Is there an easy way I can get the kind of access I need from the DE witout having to go to VI for writing a PHP script?

lewashby 56 Junior Poster

Thanks cereal, it's working now that I moved the phpinfo.php file into /var/www instead. Thanks again.

lewashby 56 Junior Poster

I just got a new Netgear N router. I didn't use the install CD because there is no computer besider our router and DSL modem. I just plugged it up and at all the Windows computers in the house seem to be able to connect just fine but my Linux computers keep failing to connect. They see it and show that there is a 74% signle but faile when connecting. The new router is almost exactly the same except that it's a new model.

lewashby 56 Junior Poster

Librarybackend: Database is locked unable to fetch row.

Any ideas?

lewashby 56 Junior Poster

Screenshot_from_2012-09-30_17:56:03

This post has no text-based content.
lewashby 56 Junior Poster

I've got an iPod classic and I'M having the worst luck moving it to my Linux. I was hoping to use Clementine or Rockbox to run the ipod but when I try rockbox I'M getting a permission denied error, even though I've added +rwx to the permissions of the devices for my user. Also, take a look at the picture I've posted for clementine, any ideas?

lewashby 56 Junior Poster

I'M converint all of my videos from iTunes using DRM removal softare. Most of these videos will be played on Linux and or my Samsung Galaxy Tab, my format options are: MPEG-1 NTSC, MPEG-1 PAS, MPEG-1 SECAM, MPEG-2 NTSC, MPEG-2 PAS, & MPEG-2 SECAM, MPG, MP4, & MKV. What should I go for here?

lewashby 56 Junior Poster

Here is the file /etc/apache2/sites-enabled/000-default

<VirtualHost *:80>
    ServerAdmin webmaster@localhost

    DocumentRoot /var/www
    <Directory />
        Options FollowSymLinks
        AllowOverride None
    </Directory>
    <Directory /var/www/>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride None
        Order allow,deny
        allow from all
    </Directory>

    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    <Directory "/usr/lib/cgi-bin">
        AllowOverride None
        Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
        Order allow,deny
        Allow from all
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

    CustomLog ${APACHE_LOG_DIR}/access.log combined

    Alias /doc/ "/usr/share/doc/"
    <Directory "/usr/share/doc/">
        Options Indexes MultiViews FollowSymLinks
        AllowOverride None
        Order deny,allow
        Deny from all
        Allow from 127.0.0.0/255.0.0.0 ::1/128
    </Directory>

</VirtualHost>

Here is /etc/apache2/apache2.conf

#
# Based upon the NCSA server configuration files originally by Rob McCool.
#
# This is the main Apache server configuration file.  It contains the
# configuration directives that give the server its instructions.
# See http://httpd.apache.org/docs/2.2/ for detailed information about
# the directives.
#
# Do NOT simply read the instructions in here without understanding
# what they do.  They're here only as hints or reminders.  If you are unsure
# consult the online docs. You have been warned.  
#
# The configuration directives are grouped into three basic sections:
#  1. Directives that control the operation of the Apache server process as a
#     whole (the 'global environment').
#  2. Directives that define the parameters of the 'main' or 'default' server,
#     which responds to requests that aren't handled by a virtual host.
#     These directives also provide default values for the settings
#     of all virtual hosts.
#  3. …
lewashby 56 Junior Poster

It sounds like you want to intrude into her computer. Without her knowing. :-/, hence the word intrude. I know of no way to do this without ssh.

lewashby 56 Junior Poster

I've set up a small php file called phpinfo.php the script is below.

<!DOCTYPE html PUBLIC "_//W3C//DTD XHTML
1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/
xhtml-transitional.dtd">
<html xmlns="http://www.w3.org/1999/
xhtml" xml:lang="en" lang="en">
<head>
    <meta http-equiv="content-type"
    content="text/tml; charset=utf-8" />
    <title>First PHP Script</title>
</head>
<body>
<?php
phpinfo();
?>
</body>
</html>

I've already installed both php5 and apache2, but when I type 127.0.0.1/phpinfo.php into the browser I get 404 Not Found. I did move the phpinfo.php file into the /usr/share/apache2/default-site directory. Now if I type 127.0.0.1 by itself I get the default index.html "It Works". Any ideas?

lewashby 56 Junior Poster

I'M sure you haven't. Thanks, I think this is going to be really helpfull. When you say it's against the law I find that very confusing since there are plenty of comercial products out there desigend for that purpos, the company pavtube offeres such products.

lewashby 56 Junior Poster

I got it guys, if you don't care take a look.

lewashby 56 Junior Poster

I'M having a bit of a problem with audio books on Linux. I buy my books from audible.com but since they don't support Linux it's just one more thing keeping me from fully leaving Windows. There audio formats are in .aax. Their books play fine in iTunes and on my iPod. Each book as multiple tracks with it's self as opposed to an audio CD where each file is a track. And it has a neat resume feature as well. It works so well infact that I'M guessing that apple build .aax support into iTunes for audible.com. I'M looking for a good auio book seller with a good audio book format that has some sort of stop/start ability to it like audible's .aax. Or if anyone has any idea on how I might convert or crack the protection on these .aax files that would be welcomed as well. I tried to import the files into audacity and also tried to convert them wiht VLC, both attempts have failed. Any suggestions? Thanks.

lewashby 56 Junior Poster

network14network22Permissions3WD-TV-Live3

This post has no text-based content.
lewashby 56 Junior Poster

It is vital the people can see the pictures I'M trying to upload in order to help me out with my computer poblem but daniweb will not upload the pics. I click "Files" in the messege tool bar and chose brows. It seem to upload them but there never on the page anywhere. There is also what looks like a buttons that says "Upload" but it doesn't do anything.

lewashby 56 Junior Poster

I keep uploading the pictures but thery're not here!!! WTF!

lewashby 56 Junior Poster

I have Western Digital TV Live that plugs into my TV and also into my 1TB external HD. I have attached four pictures to help with what I'M confused and having trouble with. Take a look at my network1.png, notice that the device is listed in two places, one big icon in the right area and one small icon listed to the lower left havigation panel. When I lick on the big WDTVLive icon in the right area I get the web page you see in WD-TV-Live.png but when I click the one to the lower left I get what you see in network2.png, it's let's me right in without a poblem. How can one icon a secure and want a password(that by the way I don't remember ever creating for the WD device or my external 1TB HD) and the other icon let me right in? And since anyone can navigate right in using the icon listed on the left navigation panel of windows exporer, anyone in the house could potentially delete the movies, not just watch them. So I decided to plug the 1TB drive into my computer and set permissions so that noone else could have write permissions, only read. Now I'M more use to Linux permissions rwx for user, group, and other/everyone else. So I don't really know what I"M doing. Please take a look at Permissions.png and tell me why there isn't others or everyone else listed from which I might remove write access. And …