Results 1 to 3 of 3
  1. #1
    help using terminal

    Member Since
    Oct 26, 2010
    Posts
    1
    help using terminal
    I'm taking a survey course of languages and we are covering perl this week. I have never used terminal before. I need to write perl script that will parse xml data, but I can't even figure out how to use the terminal.
    when I open the terminal I get this line(I subed out my name and username):

    firstName-LastName-MacBook-Pro:~ username$

    i have tried the commands ls and that works, but I can't figure out how to run scripts from a file. I have tried a simple hello world app by typing:

    #!/usr/local/bin/perl
    print "Hello World!\n";

    in text edit saving it as hello.pl then I tried to type hello.pl in the terminal and it says
    -bash: first.pl: command not found

    can someone explain in simple terms how to run simple programs like this?

    thanks, aaron

  2. #2
    help using terminal
    cradom's Avatar
    Member Since
    Feb 14, 2004
    Location
    Nederland, Texas
    Posts
    4,082
    Specs:
    13in macbook - 10.10.4
    Find yourself a website on using the Bash shell and shell scripting. Here are a couple to get started:
    LinuxCommand.org: Learn the Linux command line. Write shell scripts.
    Bash Prompt HOWTO

    Also make sure you're saving the files as plain text if you're using TextEdit. You might want to consider using Nano in Terminal instead.
    To run the script, make sure the file is excutable (chmod +x filename) and preface the filename with a ./ to run it. This will tell the shell the file is in the current directory.

  3. #3
    help using terminal
    IvanLasston's Avatar
    Member Since
    Feb 26, 2010
    Location
    Rocky Mountain High, Colorado
    Posts
    2,116
    Specs:
    1.8 GHz i7 MBA 11" OSX 10.8.2
    First you have to figure out where perl is -
    Code:
    which perl
    Make sure that matches what you put in the #! line - mine is actual in /opt/local/bin

    If you want to run the script you have to set it to executable
    Code:
    chmod 755 first.pl
    Then you can do
    Code:
    ./first.pl
    Which should run.

    Here is a little more info on permissions
    Linux and UNIX chmod command help

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Month in Terminal is in Russian - only in Terminal!
    By yoandrew in forum OS X - Operating System
    Replies: 4
    Last Post: 12-29-2012, 09:20 AM
  2. Terminal Help?
    By gts1117 in forum OS X - Operating System
    Replies: 2
    Last Post: 08-20-2012, 09:25 AM
  3. Terminal Help
    By LMCLUMD in forum OS X - Development and Darwin
    Replies: 1
    Last Post: 06-15-2011, 04:08 AM
  4. help!! terminal os 10.5.8
    By alcohol in forum OS X - Operating System
    Replies: 10
    Last Post: 04-10-2011, 12:35 PM
  5. using terminal
    By mayflyTR in forum OS X - Operating System
    Replies: 3
    Last Post: 08-22-2010, 05:56 PM

Posting Permissions

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