Thread: help using terminal
10-26-2010, 08:38 AM #1
help using terminal
- Member Since
- Oct 26, 2010
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):
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:
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?
10-26-2010, 09:34 AM #2
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.
10-28-2010, 09:33 PM #3
- Member Since
- Feb 26, 2010
- Rocky Mountain High, Colorado
- 1.8 GHz i7 MBA 11" OSX 10.8.2
First you have to figure out where perl is -
If you want to run the script you have to set it to executable
chmod 755 first.pl
Here is a little more info on permissions
Linux and UNIX chmod command help
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
By yoandrew in forum OS X - Operating SystemReplies: 4Last Post: 12-29-2012, 09:20 AM
By gts1117 in forum OS X - Operating SystemReplies: 2Last Post: 08-20-2012, 09:25 AM
By LMCLUMD in forum OS X - Development and DarwinReplies: 1Last Post: 06-15-2011, 04:08 AM
By alcohol in forum OS X - Operating SystemReplies: 10Last Post: 04-10-2011, 12:35 PM
By mayflyTR in forum OS X - Operating SystemReplies: 3Last Post: 08-22-2010, 05:56 PM