SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Wizard
    Join Date
    Jan 2005
    Location
    blahblahblah
    Posts
    1,447
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Executing from the command line

    Hello,

    I will have to write some code that can be triggered from the command line
    Code:
    $ myapp do something
    .

    Is ruby the way to go? Is Python better?



    Regards,

    -jj.

  2. #2
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    5,358
    Mentioned
    179 Post(s)
    Tagged
    9 Thread(s)
    Hi there,
    What does your code have to do?
    If you ask me, Ruby is definitely the way to go, but I am biased

  3. #3
    SitePoint Wizard
    Join Date
    Jan 2005
    Location
    blahblahblah
    Posts
    1,447
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Upload/Download files + connect to an API

    Sounds like Ruby wil do the trick.

  4. #4
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    5,358
    Mentioned
    179 Post(s)
    Tagged
    9 Thread(s)
    Quote Originally Posted by jjshell View Post
    Upload/Download files + connect to an API

    Sounds like Ruby wil do the trick.
    Indeed.

    Uploading can be done with Net::FTP

    Downloading like this:
    Code Ruby:
    #!/usr/bin/env ruby
    `wget http://yourdomain.com/flv/sample/sample.flv`

    or with Net::HTTP

    Connecting to an API would depend on the API in question.

  5. #5
    SitePoint Member
    Join Date
    Feb 2013
    Location
    Salt Lake City, UT
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ruby's a great command-line language, especially if you're already familiar with it. You can use all of the gems the ruby community has already written for talking to all sorts of APIs. HTTParty and Faraday are both great http client gems that make it super easy to work with remote APIs.

  6. #6
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2006
    Location
    Augusta, Georgia, United States
    Posts
    4,053
    Mentioned
    16 Post(s)
    Tagged
    3 Thread(s)
    You can just write any old ruby script and execute it from the command file. You can also do the same with several other languages. Nothing new really.

    ruby name_o_file.rb
    The only code I hate more than my own is everyone else's.


Bookmarks

Posting Permissions

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