LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
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 01-31-2008, 03:47 PM   #1
bkdc
LQ Newbie
 
Registered: Jan 2008
Location: Tampa, Fl. USA
Distribution: PCLinuxOS 2007
Posts: 7

Rep: Reputation: 0
Errors running bash script files


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.

Last edited by bkdc; 01-31-2008 at 03:50 PM.
 
Old 01-31-2008, 06:46 PM   #2
bigrigdriver
LQ Addict
 
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian stable
Posts: 5,908

Rep: Reputation: 356Reputation: 356Reputation: 356Reputation: 356
Code:
#!/usr/bin/bash
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.
 
Old 01-31-2008, 07:15 PM   #3
gankoji
Member
 
Registered: Nov 2007
Location: Southern California
Distribution: Slackware-13.0 x86_64, Slackware 12.2, slackware64-current
Posts: 225

Rep: Reputation: 35
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.

Happy Hunting :-)
 
Old 01-31-2008, 10:17 PM   #4
aus9
LQ 5k Club
 
Registered: Oct 2003
Location: Western Australia
Distribution: Icewm
Posts: 5,842

Rep: Reputation: Disabled
lets make a simple script to test as non root

-------------copy and paste into editor------
#!/bin/bash
echo "I am not a pervert"
------------------------------------------

save the file in your home directory....I named it pervert

make it executable
Code:
chmod 700 pervert
ls -l pervert
output>>>>>-rwx------ 1 gordy gordy 38 2008-02-01 13:12 pervert*

run it....I have not added pathway = where ever to .bashrc so use the ./executable style

Code:
./pervert
output >>>>>I am not a pervert
 
Old 02-01-2008, 06:20 AM   #5
bigrigdriver
LQ Addict
 
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian stable
Posts: 5,908

Rep: Reputation: 356Reputation: 356Reputation: 356Reputation: 356
har! har! har!

You are quite the comedian.

I like you sense of humor aus9.

Soon as I win the lottery, I'll book a trip to Austraila to meet you face to face and shake your hand.

Or perhaps drop one of those funnel-web beasties down your collar.

I haven't decided which yet.

Last edited by bigrigdriver; 02-01-2008 at 07:40 AM.
 
Old 02-01-2008, 07:34 AM   #6
bkdc
LQ Newbie
 
Registered: Jan 2008
Location: Tampa, Fl. USA
Distribution: PCLinuxOS 2007
Posts: 7

Original Poster
Rep: Reputation: 0
Thanks for all the input

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.
 
Old 02-01-2008, 07:44 AM   #7
bigrigdriver
LQ Addict
 
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian stable
Posts: 5,908

Rep: Reputation: 356Reputation: 356Reputation: 356Reputation: 356
And community support comes through again. Pray tell, how much were your charged, either for the software, or the script support?
 
  


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
To rename files in a directory should I use Bash script or a Perl Script ? jamtech Programming 7 01-22-2008 11:25 PM
Bash script. Rsync and MSSQL errors and logging. nattflyger Programming 4 07-19-2006 08:57 AM
running su from a bash script caminoix Programming 7 12-28-2005 03:41 PM
Errors When Running My Backup Script cdurante Red Hat 4 12-28-2005 11:45 AM
Running bash script files in C++ (Kylix) Acherion Programming 4 07-25-2003 11:35 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:45 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
Open Source Consulting | Domain Registration