LinuxQuestions.org
Visit Jeremy's Blog.
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 09-01-2005, 08:34 PM   #1
comosea
LQ Newbie
 
Registered: Sep 2005
Posts: 6

Rep: Reputation: 0
Need to save time...


I am using gas, but to execute a program I have to write three commands. I know I can press the "up" arrow to see the latest commands I've used, but still it takes a lot of time to look for the commands when I've used others. Is there an easiest way of writing a serie of commands?

Last edited by comosea; 09-01-2005 at 08:43 PM.
 
Old 09-01-2005, 08:45 PM   #2
bosewicht
Senior Member
 
Registered: Aug 2003
Location: Honolulu, HI
Distribution: Arch
Posts: 1,380

Rep: Reputation: 47
write a shell script
#!/bin/sh
echo "Hello world "
 
Old 09-01-2005, 08:50 PM   #3
comosea
LQ Newbie
 
Registered: Sep 2005
Posts: 6

Original Poster
Rep: Reputation: 0
Where can I find information about shell script's? (I'm a complete newbie)
 
Old 09-01-2005, 08:52 PM   #4
bosewicht
Senior Member
 
Registered: Aug 2003
Location: Honolulu, HI
Distribution: Arch
Posts: 1,380

Rep: Reputation: 47
www.google.com
http://www.freeos.com/guides/lsst/
 
Old 09-01-2005, 08:56 PM   #5
comosea
LQ Newbie
 
Registered: Sep 2005
Posts: 6

Original Poster
Rep: Reputation: 0
thanks
 
Old 09-01-2005, 09:45 PM   #6
mfrick
Member
 
Registered: Sep 2004
Location: Perth
Posts: 51

Rep: Reputation: 15
very basically though ....
in a file called blah.sh (the #!/bin/sh must be on the 1st line)

#!/bin/sh
command 1
command 2
command 3

then change the permissions on the file so it is executable (chmod 755 blah.sh or similar)
then to execute # ./blah.sh

Last edited by mfrick; 09-01-2005 at 11:00 PM.
 
Old 09-01-2005, 10:23 PM   #7
IBall
Senior Member
 
Registered: Nov 2003
Location: Perth, Western Australia
Distribution: Ubuntu, Debian, Various using VMWare
Posts: 2,088

Rep: Reputation: 62
For some further info:
Advanced Bash Scripting Guide
Bash Programming Introduction

I hope this helps
--Ian
 
Old 09-01-2005, 10:28 PM   #8
comosea
LQ Newbie
 
Registered: Sep 2005
Posts: 6

Original Poster
Rep: Reputation: 0
Thank you!!! (all of you). I think that with those three guides and the example I have enough.
 
Old 09-02-2005, 03:21 PM   #9
comosea
LQ Newbie
 
Registered: Sep 2005
Posts: 6

Original Poster
Rep: Reputation: 0
ok, I've made the script.

Quote:
#!/bin/sh
cd $1
as -o $1.o $1.s
ld -o $1 $1.o
./$1
cd ..
It works fine. The problem is that I want to use it like a command. I readed that in order to make that, I must make a directory called "bin" on my home. I did that and copied the script to it. But it doesn't work.

Quote:
-bash: ensamble: command not found
WHY??? :'(

P.D. : The script name is "ensamble.sh".

Last edited by comosea; 09-02-2005 at 03:22 PM.
 
Old 09-02-2005, 03:31 PM   #10
bosewicht
Senior Member
 
Registered: Aug 2003
Location: Honolulu, HI
Distribution: Arch
Posts: 1,380

Rep: Reputation: 47
Quote:
Originally posted by mfrick
then change the permissions on the file so it is executable (chmod 755 blah.sh or similar)
then to execute # ./blah.sh
So you would cd to wherever you saved it and type ./ensamble.sh
 
Old 09-02-2005, 03:36 PM   #11
comosea
LQ Newbie
 
Registered: Sep 2005
Posts: 6

Original Poster
Rep: Reputation: 0
I know, that's how I know it works fine. the problem is that, as you see it uses "cd" and "as" and I have several folders where the script is usefull, and I don't want to have all over my HOME copies of the script.
 
Old 09-02-2005, 03:59 PM   #12
celticgeek
Member
 
Registered: Jul 2005
Location: Lothlorien
Distribution: CentOS 4.4, currently
Posts: 30

Rep: Reputation: 15
Bash Script

As root, move the file ensamble.sh in the /bin directory. MAKE SURE than no other program in the /bin directory has the same name. The file will then be accessible to anyone using the computer, even if they are not the root user.

This assumes that /bin is in your path. Check by typing "echo $PATH " (without the quotes) at the prompt. Usually /bin is in the PATH variable by default.

Last edited by celticgeek; 09-02-2005 at 04:00 PM.
 
Old 09-02-2005, 04:04 PM   #13
bosewicht
Senior Member
 
Registered: Aug 2003
Location: Honolulu, HI
Distribution: Arch
Posts: 1,380

Rep: Reputation: 47
add it to your local path if you are the only one running it or system wide for any user
 
Old 09-02-2005, 09:02 PM   #14
IBall
Senior Member
 
Registered: Nov 2003
Location: Perth, Western Australia
Distribution: Ubuntu, Debian, Various using VMWare
Posts: 2,088

Rep: Reputation: 62
The best thing is to create a bin directory in your home. You then need to add this directory to your $PATH. Add the following line to your ~/.bashrc:
Code:
export PATH=$PATH:~/bin
Then you can run this script from anywhere, but other users on your computer can't. Put it in /usr/bin if you need all users on the machine to be able to use it.

I hope this helps
--Ian
 
  


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
Doub about `net time set` and daylight saving time Thakowbbery Linux - Software 0 10-17-2005 05:23 AM
ps2 mouse freezing on FC1/FC2 from time to time farpoint Linux - Hardware 5 08-14-2005 02:20 PM
no signal when starting xorg for the 1st time (but the second time works fine) bungalowbill Linux - Software 0 06-04-2004 09:56 AM
Setting System Time: kernel in wrong time zone warrenweiss Linux - General 7 05-15-2004 03:25 PM
live distro question: can i save my settings for next time? shapdaddy Linux - Laptop and Netbook 1 04-12-2004 12:15 AM


All times are GMT -5. The time now is 05:23 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration