LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-06-2008, 09:22 AM   #1
kratosal
LQ Newbie
 
Registered: Mar 2008
Posts: 13

Rep: Reputation: 0
how to make any file executable


ok i read that it is made by command chmod + x<filename>

but take a look at this program in perl
!/usr/bin/Perl -w
author:
modified by:
date:
Purpose: Hello World
print "hello world";
END

now first i typed this, now how will i make this file executable, do i have to first write this piece of code and then enter and then that chmod thing, well that didnít work......... plzzzz help
 
Old 04-06-2008, 09:27 AM   #2
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 670Reputation: 670Reputation: 670Reputation: 670Reputation: 670Reputation: 670
You left out the octothorpe character and tried to run comments.
 
Old 04-06-2008, 09:42 AM   #3
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738
Quote:
Originally Posted by jschiwal View Post
You left out the octothorpe character and tried to run comments.
That is a marvelous word!!! I lived for over 60 years before learning it--and then I had to come to LQ to do so.

On the off chance that OP does not know what it means, we're looking for this:

#!/usr/bin/Perl -w

(And add # to all the lines which are not legal commands.)
 
Old 04-06-2008, 09:43 AM   #4
kratosal
LQ Newbie
 
Registered: Mar 2008
Posts: 13

Original Poster
Rep: Reputation: 0
hey look man i a, just a newbie jschiwal and u were way over my head plz tell me the exact procedure, if u could........... thanx
 
Old 04-06-2008, 10:07 AM   #5
kratosal
LQ Newbie
 
Registered: Mar 2008
Posts: 13

Original Poster
Rep: Reputation: 0
hey plz note there is indeed a # before every line........

plz tell me when should i use chmod thing before or after or when and exactly how
 
Old 04-06-2008, 10:15 AM   #6
Maligree
Member
 
Registered: Mar 2008
Distribution: Gentoo, CentOS, Fedora, Arch
Posts: 231
Blog Entries: 1

Rep: Reputation: 42
Create the script, save it, run chmod +x your_script, run with ./your_script, where's the problem?
 
Old 04-06-2008, 02:53 PM   #7
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738
Quote:
Originally Posted by kratosal View Post
hey plz note there is indeed a # before every line........

plz tell me when should i use chmod thing before or after or when and exactly how
The "#" denotes a comment---if there is a "#" on every line, then nothing will execute.

The "#!" has to be on the first line to tell the system what language is used to interpret the script.

chmod is used to change permissions on an existing file---i.e. you first create the file, then you set the permissions.

What books have you read on all this? Now might be the time to go to http://tldp.org and get Bash Guide for Beginners, or the Advanced Bash Scripting Guide.
 
Old 04-06-2008, 03:10 PM   #8
marquardl
Member
 
Registered: Apr 2008
Posts: 100

Rep: Reputation: 15
#!/usr/bin/perl

Quote:
i read that it is made by command chmod + x<filename>
Remove the space between the '+' and the 'x' and use a space between 'x' and filename:

Code:
chmod +x <filename>
chmod a+x <filename> # better, as more specific
Your script will fail even so: it has a bad she-bang line and a couple non-statement lines uncommented.

Do:
Code:
#!/usr/bin/perl
print "Hello World\n"
Bye,
M

Linux Archive

Last edited by marquardl; 05-01-2008 at 02:37 AM.
 
Old 04-08-2008, 04:50 AM   #9
kratosal
LQ Newbie
 
Registered: Mar 2008
Posts: 13

Original Poster
Rep: Reputation: 0
hey thanx to all for ur kind help
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I make a shortcut to an executable? lakedude Linux - Software 3 03-10-2008 10:56 PM
Howto convert bin file to a executable DOS file lilzz Linux - Newbie 5 08-04-2006 01:03 AM
Make newly created file executable Black Chaos Linux - General 3 08-03-2006 11:53 AM
How to make a bin file executable and install the prgram shariqali Linux - Software 6 03-29-2006 02:11 PM
How to make a firefox executable available to all users bigfatdud Linux - Newbie 5 12-28-2004 07:08 PM


All times are GMT -5. The time now is 06:41 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration