Find the answer to your Linux question:
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 11
This should really read Python noob but at the time I posted this I was considering PHP instead of Python - I am stationed at a Windows 8 station - ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Feb 2014
    Posts
    6

    Post PHP Noob seeking assistance with basic script


    This should really read Python noob but at the time I posted this I was considering PHP instead of Python


    - I am stationed at a Windows 8 station
    - The script will be set to run from an EC2 of Linux
    - I need Python to log in to a godaddy FTP we have setup (using username and password) or out to our EC2 Linux instance on our AWS again username and password)
    - Needs to search the root directory for newest files based on date... There are also specific naming conventions different clients use, but I assume via date will be much easier for when clients misname things
    - These files need to be moved from the FTP over to our cloud storage (cloud storage = Egnyte, the drive is mapped on my workstation though)
    - From here we need to decrypt the files, they are encrypted with PGP and we are using Symantec.. There are few different sets of passphrases we use here so I will need it to try one and if that one is not it move to next
    - from here we are essentially done, there is more to the process I will be doing manually that I want to automate in the future but for now I am taking "baby steps" Because just doing this will save me countless hours.
    I should note that certain files come in on certain days, or rather they are supposed to. Any sort of sample scripts I can look at would be greatly beneficial and would enhance my understanding of the process.
    Python will be the choice here. Please ask any clarification questions. Any help is extremely appreciated
    Last edited by Joshuas; 02-26-2014 at 09:11 PM. Reason: to clarify

  2. #2
    Just Joined! mrbruno's Avatar
    Join Date
    Jan 2013
    Location
    /MilkyWay/Sol/Earth/USA/NC/Raleigh
    Posts
    65
    I'm not sure PHP is the best choice - typically PHP is used to respond to an incoming HTTP request. I suppose you could trigger a HTTP request periodically but that sounds more complicated than it needs to be. You might want a more native scripting language (personally, I might try to do it in Python or bash) triggered by cron.

    I'm curious - does your FTP server require a real password or just an anonymous one? If it's a real password, you might have to take a serious look at protecting your password.

    You also mentioned decrypting the files. Are you hardcoding a private key in your script??

  3. #3
    Just Joined!
    Join Date
    Feb 2014
    Posts
    6
    The files are all PGP encrypted and we are decrypting with symantec using unique keys. The FTP is also password secured, everything has set credentials. I had also done some research and Python has come up a few times. Where is a good place to start here if I were utilizing Python, any online documentation for utilizing it for similar processes? We are utilizing a Unix platform so doing this in bash is also an option. Its an Amazon AMI Linux instance to be specific.

  4. #4
    Just Joined! mrbruno's Avatar
    Join Date
    Jan 2013
    Location
    /MilkyWay/Sol/Earth/USA/NC/Raleigh
    Posts
    65
    I'm not sure what you mean by utilizing it for similar processes. Can you elaborate? It provides access to many of the base Unix system interfaces we all know and love. If you're talking about spawning off children to do work, I'm sure that's do-able.

    The Python site has a good tutorial and excellent reference material. I'm still fairly new to Python myself and often find a simply-phrases Google search will help guide me to do specific things. It's a very rich language!! There might even be some packages that substitute for using curl and can be more convenient to use.

  5. #5
    Just Joined!
    Join Date
    Feb 2014
    Posts
    6
    Oh, I guess I mean exact same process, mainly need to download files, decrypt, then store on our cloud source which is mapped to a local drive. We have a guy in our department who is somewhat familiar with php and had written some code for this already, but claims it doesnt work properly. I have been tasked with the research piece as far as exploring alternatives. I am leaning towards python, I will have to dive in to the Python website I am sure what I am trying to do is a fairly easy task to automate for those with scripting and python knowledge, but my scripting experience has been in classroom settings years ago and has not been utilized for practical application.

  6. #6
    Linux User
    Join Date
    Dec 2009
    Posts
    264
    I would suggest Bash ...

  7. #7
    Just Joined!
    Join Date
    Feb 2014
    Posts
    6
    Quote Originally Posted by zombykillah View Post
    I would suggest Bash ...
    Can you elaborate a little more or provide a link to a generic bash script that does this. Are you suggesting implementing software to allow my windows environment to run Bash scrips?

  8. #8
    Linux Engineer
    Join Date
    Dec 2013
    Posts
    1,177
    Python has the tools you need for this. You can also do it using standard unix tools and shell (bash) script but if FTP is the only access you have it will be a little simpler with the Pythons ftplib.
    20.8. ftplib ? FTP protocol client ? Python v2.7.6 documentation

  9. #9
    Just Joined!
    Join Date
    Feb 2014
    Posts
    6
    This resource helps, any other suggestions for implementation would be appreciated. I havent touched Python since probably 2010 where I used it in school.... I just need to implement this within the week.

  10. #10
    Linux Engineer
    Join Date
    Dec 2013
    Posts
    1,177
    Like any program you'll need to map the steps you need to the facilities available from the language or os. For instance:

    Connect to server.
    CD to directory.
    Get Listing.
    Check dates.
    Download appropriate files.
    Close server connection.
    Decrypt files.
    Save files.

    You want to run this on a schedule so read up on the utility cron.

Page 1 of 2 1 2 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •