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
Welcome to
LinuxQuestions.org , a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free.
Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please
contact us . If you need to reset your password,
click here .
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a
virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month.
Click here for more info.
09-02-2011, 12:17 AM
#1
LQ Newbie
Registered: Apr 2007
Posts: 25
Rep:
Clear: Command not found
I am trying to learn shell scripting and the first attempt is an error
I found this tutorial :
http://www.freeos.com/guides/lsst/ch02sec01.html
and made the sample program.
basically the script just contains clear
but I got the error
the clear command is located at my /usr/bin
which is already set in my PATH
I am running bash shell.
09-02-2011, 12:44 AM
#2
Senior Member
Registered: Jan 2005
Location: Nottingham, UK
Distribution: Mageia 6, KDE Neon
Posts: 4,313
Are you sure you have
/usr/bin in your path? You can check with
If /usr/bin is not listed you need to add it to your /home/username/
.bash_profile file.
09-02-2011, 12:46 AM
#3
LQ Guru
Registered: Dec 2008
Location: Westgate-on-Sea, Kent, UK
Distribution: Debian Testing Amd64
Posts: 5,465
Rep:
Did you make your script executable?
jdk
Last edited by jdkaye; 09-02-2011 at 12:49 AM .
09-02-2011, 01:43 AM
#4
LQ Newbie
Registered: Apr 2007
Posts: 25
Original Poster
Rep:
yes it is in my path::
$echo $PATH
/usr/local/bin:/bin:/usr/bin
yes it is executable:
-rwxrwxrwx testsh.sh
09-02-2011, 01:52 AM
#5
Senior Member
Registered: Jan 2005
Location: Nottingham, UK
Distribution: Mageia 6, KDE Neon
Posts: 4,313
What happens if you simply type clear yourself? BTW what distro are you using?
09-02-2011, 01:53 AM
#6
Member
Registered: Apr 2010
Distribution: Fedora
Posts: 109
Rep:
1. Output of
or
2. Do you see an error when 'clear' is executed?
3. Output of
Quote:
sh -x <name of your script>
09-02-2011, 02:03 AM
#7
LQ Newbie
Registered: Apr 2007
Posts: 25
Original Poster
Rep:
if i simply type clear, it clears the screen
$which clear
/usr/bin/clear
distro; Redhat
I tried doing this:
code=clear
the error was gone, but it did not execute the clear command.
09-02-2011, 02:09 AM
#8
Member
Registered: Apr 2010
Distribution: Fedora
Posts: 109
Rep:
Quote:
Originally Posted by
gloridel
if i simply type clear, it clears the screen
$which clear
/usr/bin/clear
distro; Redhat
I tried doing this:
code=clear
the error was gone, but it did not execute the clear command.
Can you paste the script here?
Are you assigning 'clear' to 'code' and calling 'code'?
09-02-2011, 02:20 AM
#9
LQ Newbie
Registered: Apr 2007
Posts: 25
Original Poster
Rep:
this is the only thing inside my testsh.sh file
i execute the script by "./testsh.sh" only
sorry , this is really my first time making my own shell script
09-02-2011, 02:22 AM
#10
Member
Registered: Apr 2010
Distribution: Fedora
Posts: 109
Rep:
No problem. Shell scripting is cool as you learn it.
well. After the line
, you have to call it as follows
Or, you can directly call 'clear' in the code.
1 members found this post helpful.
09-02-2011, 02:31 AM
#11
Senior Member
Registered: Jan 2005
Location: Nottingham, UK
Distribution: Mageia 6, KDE Neon
Posts: 4,313
Quote:
Originally Posted by
gloridel
That is not even in the tutorial you said you followed.
09-02-2011, 02:32 AM
#12
LQ Newbie
Registered: Apr 2007
Posts: 25
Original Poster
Rep:
i forgot to put this line
and there where some extra characters so i got the following errors
-bash: ./testsh.sh: /bin/bash^ bad interpreter
so I used vi this time and wrote the function again and its working like magic
thank you so much
09-02-2011, 02:34 AM
#13
LQ Newbie
Registered: Apr 2007
Posts: 25
Original Poster
Rep:
Quote:
Originally Posted by
{BBI}Nexus{BBI}
That is not even in the tutorial you said you followed.
sorry about that,
the original code was
Code:
clear
echo "Hello $USER"
echo "Today is \c"; date
echo "Number of user login : \c"; who | wc -1
cal
exit 0
but I got some errors command not found, so I was experimenting with it and posted the latest code I had ..
09-02-2011, 02:34 AM
#14
Member
Registered: Apr 2010
Distribution: Fedora
Posts: 109
Rep:
Well... if you ever encountered such error due to extra characters... this happens if you used editors on Windows...
you can resolve it by converting the script to unix format...
Quote:
dos2unix <name_of_ur_script>
09-02-2011, 02:41 AM
#15
LQ Newbie
Registered: Apr 2007
Posts: 25
Original Poster
Rep:
Quote:
Originally Posted by
hi2arun
Well... if you ever encountered such error due to extra characters... this happens if you used editors on Windows...
you can resolve it by converting the script to unix format...
thanks.
All times are GMT -5. The time now is 12:47 PM .
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know .
Latest Threads
LQ News