Linux - NewbieThis 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.
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.
Here is a summary of my problem, following is a simple script & results. Problem:
I am having a problem running even the most simple bash script file. I have tried everything that I could think of but nothing seems to correct the problem. My feeling that it may be something really stupid (I've been away from this stuff for several years & now trying to get back into it).
Linux distro is PCLinxOS 2007
Here is a sample script & the related problems. I have cut & pasted the command lines into a Konsole window & all works fine but running as a bash script is another story. PLEASE NOTE: That this scenario is true for any script I try, no just this one. Script used for testing
#!/usr/bin/bash
# Disk Usaage test Script
# List directory contents
#
Dir=`pwd`
clear
echo "Current directory is $Dir \n"
echo "Disk Usage is as follows...\n"
echo "File by size 0....999999\n"
du -s *|sort -rnk 1,1
Test Results from attempt to run
: command not found
\nrent directory is /home/df10475
Disk Usage is as follows...\n
File by size 0....999999\n
sort: stray character in field spec: invalid field specification `1,1\r'
df10475@~ :$
Thing I have done:
- Verified /etc/passwd etc/profile $HOME/bash_profile PATH
- Tried running as ROOT (same results)
- Re-entered the script using vi instead of KWrite
- Re-installed bash
I am open to all suggestions & a second set of eyes.
I have only been using PCLOS for about 2 months & this is the first attempt at scripting using this distro.
Every distro I've used so far, bash is in /bin, not /usr/bin.
Change it to
Code:
#!/bin/bash
To verify where bash in in PCLOS, in a console window, enter 'which bash' (without quotes).
You might also try splitting up the du command line. Put the du -s * part at the end of the 'disk usage' line, and the sort -mk 1,1 part at the end of the 'file by size' line.
PS: I've got a working copy of the corrected code which still needs a minor tweak or two to format display. If you haven't solved it in a couple of days, show me what you've got. Then I'll show you mine.
No kinky thoughts from you perverts please.
Last edited by bigrigdriver; 01-31-2008 at 07:23 PM.
bigrig makes a good point that you should keep in mind even if it doesn't fix your specific problem: /usr/bin is not the same as /bin. If it is, you've screwed something up horribly :-P. Something to keep in mind for your future scripting expeditions.
Good news for gankoji, I did not screw up however I did mess up a little. BASH is in the correct directory, my brain was not...I know better but for some reason never gave it a thought. Once I made the change suggested by bigrigdriver everything appears to be working again, even the pervert script by aus9.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.