iNeedsHelp
Posts: 15
Joined: Mon Jan 25, 2016 7:42 pm

Raspberry Pi 2 model B PuTTY, and Programming help needed

Fri Jan 13, 2017 1:21 am

Okay so hi, quick introduction, I am a 15 year old boy who has been interested in programming and website design for a while now and I would like some help with a few things... I am in desperate need of this, because I need to have something done or made by FEB 26 this year, and I am still a complete noob at this, so I gotta get my stuff together ASAP.

1. I keep trying to run the tight vnc viewer, but I need a password for it, but every time I type in the commands "sudo apt-get install tightvncserver" "sudo apt-get install tight vnc server" and finally to run the program "tightvncserver'... But nothing pops up for the password... which I should have after typing in the last command... anyone know the problem? I would love to use my Pi through the tight vnc viewer.

2. If no one knows how to fix it, does anyone know any good programs to run or download for web design? I am using a windows 10 computer laptop.

3. Does anyone know any good tutorials to use for how to have a wired Ethernet connection to my pi? At the moment I have a wireless connection which is messing up our internet, so I hope the wired connection would make It better off for us.

4. does anyone know a good program to use to develop code and or websites?

5. Last but not least, I need to figure out some way to impress my dad within the time frame I mentioned earlier, which if you skipped it, FEB 26, my birthday, does anyone know any easy things to impress my dad with? Cause I am a complete noob and need something fairly simple, he does not know how to code or do anything besides Microsoft Excel, so even a simple little program would make him happy.

If you need any other info or I did not word something right or some odd thing... tell me please, and ask for any useful info you might need to help me solve my problems

ejolson
Posts: 5477
Joined: Tue Mar 18, 2014 11:47 am

Re: Raspberry Pi 2 model B PuTTY, and Programming help neede

Fri Jan 13, 2017 4:54 am

iNeedsHelp wrote:so even a simple little program would make him happy.
You are on a very short time frame. My recommendation is to make up your own computerized Mad Libs story. Generally this is done by writing a couple paragraphs about something--maybe about Dad, your family or your dog--and then deleting some of the nouns, verbs, adjectives, adverbs, exclamations and so forth from the original story. The program should begin by asking questions like "type in a noun" and "type in a color" and things like that, one for each blank. After answering all the questions, the program should then insert the words into the story and display the result.

This can easily be done with a web forms interface, but since you are pressed for time it might be better to do it all in Python. Good luck!

pcmanbob
Posts: 9612
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Raspberry Pi 2 model B PuTTY, and Programming help neede

Fri Jan 13, 2017 10:19 am

HI.

For a wired connection all you need is to plug a Lan cable in to your Pi and the router and then boot the Pi it will get an address automatically. To find out the address you can just type

Code: Select all

hostname -I
in a terminal window or at the commend line.

If you want to set up a fixed IP address for your PI , you may be able to assign an address from from you router using its web interface, look for something called address reservation.

If you want to set a fixed IP on your Pi its self then its as simple as this but you need to know various bits of information about your network addressing, your router IP, the address range that it assigns using DHCP so that you can set an address outside of this range to prevent conflicts. ( you may need to change the address range that the router DHCP uses to achieve this).

Despite lots of confusing information out there, it is actually pretty straightforward to set a static address in Raspbian.

Being by editing the file dhcpcd.conf (do not use /etc/network/interfaces anymore!)

Code: Select all

sudo nano  /etc/dhcpcd.conf
Then all you need to do is append this to the bottom of the file, substituting the correct IP address and interface identifier you want.

Code: Select all

interface eth0
static ip_address=192.168.1.141/24
static routers=192.168.1.1
static domain_name_servers=192.168.1.1
Restart your Pi to apply the changes.

if you need any more help please just ask....
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

iNeedsHelp
Posts: 15
Joined: Mon Jan 25, 2016 7:42 pm

Re: Raspberry Pi 2 model B PuTTY, and Programming help neede

Fri Jan 13, 2017 12:50 pm

ejolson wrote:
iNeedsHelp wrote:so even a simple little program would make him happy.
You are on a very short time frame. My recommendation is to make up your own computerized Mad Libs story. Generally this is done by writing a couple paragraphs about something--maybe about Dad, your family or your dog--and then deleting some of the nouns, verbs, adjectives, adverbs, exclamations and so forth from the original story. The program should begin by asking questions like "type in a noun" and "type in a color" and things like that, one for each blank. After answering all the questions, the program should then insert the words into the story and display the result.[\quote]


That is an awesome idea, and fairly straight forward, I'm a noobie at this, but I can definatly write code like that, do you know how I can get access to a python terminal? I cant use my Pi through the tightvnc viewer so I got to find another program or something unless I can run python through my raspberry pi's PuTTY terminal

iNeedsHelp
Posts: 15
Joined: Mon Jan 25, 2016 7:42 pm

Re: Raspberry Pi 2 model B PuTTY, and Programming help neede

Fri Jan 13, 2017 12:52 pm

Hey, thank you for your tutorial, it is fairly simple as you said, but I need to know (probably not reading something right) where do I want to type all this into? The cmd? or my PuTTY terminal?

pcmanbob
Posts: 9612
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Raspberry Pi 2 model B PuTTY, and Programming help neede

Fri Jan 13, 2017 2:03 pm

iNeedsHelp wrote:Hey, thank you for your tutorial, it is fairly simple as you said, but I need to know (probably not reading something right) where do I want to type all this into? The cmd? or my PuTTY terminal?
If you are sat at your Pi with a screen & keyboard then you can use the terminal program to do this I am presuming you have a full copy of raspbian running with a gui/desktop, if you are only using raspbian jessie lite then you will be at the command line anyway.

If you want to do this via putty then you are already at the command line so you can just do it from there. you will of course need to find you Pi's new IP address once you change over to a wired connection before you can use putty to connect to it.

if you explain how you are using you PI and what version of raspbian you are using I will try and help in more detail.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

jbudd
Posts: 1446
Joined: Mon Dec 16, 2013 10:23 am

Re: Raspberry Pi 2 model B PuTTY, and Programming help neede

Sat Jan 14, 2017 11:05 am

My apologies if you already know this, but some basic stuff that might help:

To write programs on the Pi you don't need the GUI, just a command line. Assuming that you can log in to the Pi with Putty from your PC, you see the Bash shell "dollar prompt". You can type in commands such as "date" or "ls". Bash executes the command, shows you the output and then another dollar prompt ready for your next command.

Code: Select all

pi@BluePi:~ $ date
Sat 14 Jan 09:40:14 GMT 2017
pi@BluePi:~ $
Your own program needs to be stored in a file, and to create/edit the file you use a text editor such as nano

Code: Select all

nano myprogram
In the editor you type the code and save it. Here is a simple example

Code: Select all

#! /bin/bash
echo "hello world"
The first line specifies which language the program is written in. In this case it's Bash shell script.

Next step is to tell the Pi that the file you just wrote is intended to be a program

Code: Select all

pi@BluePi:~ $ ls -l myprogram
-rw-r--r-- 1 pi pi 26 Jan 14 09:49 myprogram
pi@BluePi:~ $ chmod +x myprogram
pi@BluePi:~ $ ls -l myprogram
-rwxr-xr-x 1 pi pi 26 Jan 14 09:49 myprogram
pi@BluePi:~ $
The "permissions" for the file now have x (for Executable) so you can run it. Type in ./myprogram

Code: Select all

pi@BluePi:~ $ ./myprogram
hello world
pi@BluePi:~ $
Here is the Hello world program in Python

Code: Select all

#! /usr/bin/python
print ("hello world")
Because your program is stored in a file it will always be there when you log in and want to run it.

You could use either Bash shell script or Python to implement ejolson's suggestion. Personally i'd do it with a shell script because that's what I'm most familiar with.

Here is a shell script which uses variables and requests user input

Code: Select all

#! /bin/bash

RAINBOW="Red Orange Yellow Green Blue Indigo Violet"     # Store a string in a variable $RAINBOW
ALLCOLOURS=$RAINBOW                                      # Copy that variable into $ALLCOLOURS

while true                                               # Start a loop which will continue indefinitely
do
read -p "Type in a colour (or CTRL C to quit) " COLOUR   # Get input from the user, store it in $COLOUR
ALLCOLOURS="$ALLCOLOURS $COLOUR"                         # Append the user input to $ALLCOLOURS
echo "All the colours I know are:" $ALLCOLOURS           # And print them all on the terminal
echo                                                     # Print a blank line
done                                                     # End of the while loop 

Return to “Beginners”