New To Mac-Forums?

Welcome to our community! Join the discussion today by registering your FREE account. If you have any problems with the registration process, please contact us!

Get your questions answered by community gurus Advice and insight from world-class Apple enthusiasts Exclusive access to members-only contests, giveaways and deals

Join today!

 
Start a Discussion
 

Mac-Forums Brief

Subscribe to Mac-Forums Brief to receive special offers from Mac-Forums partners and sponsors

Join the conversation RSS
OS X - Development and Darwin Discussion and questions about development for Mac OS X.

help using terminal


Post Reply New Thread Subscribe

 
Thread Tools
aaron4osu

 
Member Since: Oct 26, 2010
Posts: 1
aaron4osu is on a distinguished road

aaron4osu is offline
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
QUOTE Thanks
cradom

 
cradom's Avatar
 
Member Since: Feb 14, 2004
Location: Nederland, Texas
Posts: 3,090
cradom has a brilliant futurecradom has a brilliant futurecradom has a brilliant futurecradom has a brilliant futurecradom has a brilliant futurecradom has a brilliant futurecradom has a brilliant futurecradom has a brilliant futurecradom has a brilliant futurecradom has a brilliant future
Mac Specs: 21in iMac core2 Duo- 13in macbook - 10.9 on both

cradom is offline
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.
QUOTE Thanks
IvanLasston

 
IvanLasston's Avatar
 
Member Since: Feb 26, 2010
Location: Rocky Mountain High, Colorado
Posts: 2,116
IvanLasston is a splendid one to beholdIvanLasston is a splendid one to beholdIvanLasston is a splendid one to beholdIvanLasston is a splendid one to beholdIvanLasston is a splendid one to beholdIvanLasston is a splendid one to beholdIvanLasston is a splendid one to beholdIvanLasston is a splendid one to behold
Mac Specs: 1.8 GHz i7 MBA 11" OSX 10.8.2

IvanLasston is offline
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
QUOTE Thanks

Post Reply New Thread Subscribe


« Best Interface Builder Tool For The Job | How to view network usage via terminal »
Thread Tools

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread
Thread Starter
Forum
Replies
Last Post
How do you change default port for Terminal Services Client for Mac? vpalhories Internet, Networking, and Wireless 1 09-01-2010 01:27 PM
Terminal Won't Open icefall5 OS X - Operating System 7 08-25-2010 08:26 AM
C++ in terminal frike OS X - Development and Darwin 2 04-04-2008 10:52 AM
Terminal problems please help CliveO OS X - Operating System 6 03-20-2007 10:04 AM
Terminal Help rs2sensen OS X - Apps and Games 1 04-25-2005 10:52 PM

All times are GMT -4. The time now is 10:44 AM.

Powered by vBulletin
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
X

Welcome to Mac-Forums.com

Create your username to jump into the discussion!

New members like you have made this community the ultimate source for your Mac since 2003!


(4 digit year)

Already a member?