LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-10-2010, 03:02 AM   #1
oldieGoldie
LQ Newbie
 
Registered: Mar 2010
Posts: 1

Rep: Reputation: 0
Bash-script basic level


Hi there
I´m like my alias a retired person, and Its never to late to learn something, I´ve just installed Ubuntu and found a tutorial online about bash-script.Manage some, but I cant to this one:

[Write a script that makes file executable and writes a message that it has been done.
If I run the command > <scriptName> <fileName> , then the file fileName should be executable and then it should indicate that fileName have been executable.]

I´ve read man pages up-n-down and search the web, and I think I should let the script use chmod and ls -l, but I cant get the hole picture here. Actually I have nothing to show up, so I hope someone could help me with some ideas or a soloution - just to the how it should look.

This is my first post, ever, at a forum like this, so please be nice if I didnt follow any rules here, I dont know if you even will answer this post, but at least give me some clues, a skeleton-code ti be based on.

Thank you!
 
Old 03-10-2010, 03:14 AM   #2
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
When writing bash scripts it is often helpful to do the things that you want the script to do manually, at the command prompt.

At the command line, how would you:
  1. make a file executable?
  2. check that you have made it executable?
You have already mentioned the chmod and ls commands as being useful.

Once you have found the commands you want the script to run, edit them into a file:
Code:
!/bin/bash
<first command>
<second command>
Then make the file executable (you know how to do that!) and run it with ./<script file name> or bash <script file name>.
 
Old 03-10-2010, 05:11 AM   #3
AnanthaP
Member
 
Registered: Jul 2004
Location: Chennai, India
Posts: 952

Rep: Reputation: 217Reputation: 217Reputation: 217
# assume $1 contains the name of the file to be made as an executable, then the script

Code:
chmod +x $1
echo $1 is made as an executable
OK
 
  


Reply



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
Basic Bash Script help mpmackenna Linux - Newbie 3 03-18-2009 10:23 AM
Which is the entry level and more basic level Linux certifications? jeancollins72 Linux - Certification 3 12-26-2008 05:14 AM
Basic Bash script help valadamir Programming 2 12-01-2004 10:37 AM
Trouble with a basic bash script Tengil Linux - Newbie 5 03-04-2004 12:59 PM
help with basic syntax in bash script Supp0rtLinux Linux - Software 4 03-27-2003 06:57 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:45 PM.

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
Open Source Consulting | Domain Registration