Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3492
  • Last Modified:

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...
0
ellandrd
Asked:
ellandrd
  • 2
  • 2
1 Solution
 
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"
0
 
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

0
 
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
0
 
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
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now