Python and PuTTY

before i start - im total new to LINUX OK!

the other day i changed from using a Microslops Windoses Server to a LINUX Server.

PHP, Perl & CGI, C++ and Python are all enabled on the LINUX server.  I have never used a python script and wanted to know how to run one.

I then contacted my host to find out how to run pythons scripts on there server and basically was told to use PuTTY adn was giving my username and password to connect to SSH something or other.

I downloaded PuTTYa nd installed it on my laptop and conected to the LINUX server, but after that - forget it - total lost.

I have no knowledge of using LINUX or its commands ut im willing to learn.

hoping somebody can provide me with some help to how to run a python script and give it permissions to run i think -im not too sure what the technical support guys are meaning about permissions...

anyways hope to hear from somebody soon...
LVL 16
ellandrdAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

sheetbirdCommented:
It sounds like the python isn't the problem or at least not yet.  First you need to learn a bit about Linux and it's shell.  The shell is the command line interface between you and the operating system much like windows "command prompt".  So now to give you a few pointers.  When you log in you will be in your "home directory" you can see where you are by typing in "pwd" (without "") which means present working directory (directory = folder).  To see what's in the directory type "ls" (lowercase LS) is like "dir" on windows.To move around you us "cd" just like in windows, cd .. to go up one directory, cd somedir to go into the somedir sub-directory, or cd /home/myuser/somedir to go directly to where ever you need to go.

So now you can move around the filesystems (some what similar to drives in Windows like c: or d: there are no drives like this in Linux, filesystems attach to the / filesystem by mounting (windows mapping) to a directory) .  the top of the filesystem is called root and is shown just by a "/".  So to get to the root of the computer just type "cd /".  To see what filesystems are on your system type in "df -h"  this will list all local and network mounted filesystems.  

Now you'll need to find you python scripts which probably under /usr somewhere.  If your lucky findutils will be installed and you can type in "locate pythonscriptname" and it will tell you where it is.

Once you find it you can run it by cd'ing to the directory it's in and running ./pythonscript   or from anywhere on the system by giving the full path name of the script /usr/local/python/pythonscript.

Also sometime you should go pick up a book of which there are thousands for Learning linux because while it's really pretty easy there is a lot of content.  Also use the man pages which will give you all the details of most any command by typing in man <command> for instance "man ls"

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ellandrdAuthor Commented:
ok thank you for these commands - they will be very helpful!

>>Once you find it you can run it by cd'ing to the directory it's in and running ./pythonscript   or from anywhere on the system by giving the full path name of the script /usr/local/python/pythonscript.

ok my full path looks like this:

/user/local/python/

my python script is called index.py so how do i call it?

like this:

/user/local/python/index

thanks

ellandrdAuthor Commented:
Mmm cant get the python script to run...

here: i copied and pasted from the PuTTY...

Using username "domain1019017".
domain1019017@ssh.x.co.uk's password:
Last login: Mon Apr  3 20:07:11 2006 from host86-131-147-213.range86-131.eircom.ie
[domain1019017@ssh5 ~]$ pwd
/home/fhlinux189/s/x.co.uk/user
[domain1019017@ssh5 ~]$ ls
htdocs  logfiles  private
[domain1019017@ssh5 ~]$ cd htdocs
[domain1019017@ssh5 htdocs]$ pwd
/home/fhlinux189/s/x.co.uk/user/htdocs
[domain1019017@ssh5 htdocs]$ ls
cgi-bin  entrance_logo.png  ERT  index.php  jws  mysql  php  python  robots.txt
[domain1019017@ssh5 htdocs]$ cd python
[domain1019017@ssh5 python]$ ls
index.py
[domain1019017@ssh5 python]$ index
-bash: index: command not found
[domain1019017@ssh5 python]$ locate index.py
/usr/share/doc/libxml2-python-2.6.16/index.py
[domain1019017@ssh5 python]$ index.py
-bash: exec: index.py: not found


hope this makes sence to you
sheetbirdCommented:
The last attempt there should work if you call it like "./index.py"

Linux has a PATH variable just like windows but most times your current directory is not in the path so ./ tells the shell where the file is in relation to the current directory (which is . )  Also you could run it right from your home directory with  "./htdocs/python/index.py "  depending on the script however it might assume you are running it from the current directory.  

"locate" did find another index.py but there are bound to be many, also it looks like the index file that locate uses hasn't been updated so run "updatedb".  This takes a few minutes.  You may need to be root to run that if so type in "su -" and then the root password then run "updatedb" .  To get back to your own shell enter <ctrl>D  

Hope that helps
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Linux

From novice to tech pro — start learning today.