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 04-01-2003, 02:41 AM   #1
roo
LQ Newbie
 
Registered: Apr 2003
Location: ireland
Posts: 2

Rep: Reputation: 0
Unhappy scripting problem,its annoying


hi i need to know how to answer the following problem,i have a version but im getting errors i can't seem to fix,any help will be appreciated:
iam required to list all executeable files in a specified directory.the script works as follows
./exexcFiles[directory][file]

if no file is specified then result is displayed to the screen.if a file is specifired the results are sent to it.errror messages are to be included also.
my version so far is:
clear
currentDir = $PWD

if [$# -gt 0 -a $# -lt 2];
then
echo "you need to enter an argument"


elif [test -d $1];
then
cd $1
touch newFile
for i in *
do
if -x $i -a -f $i
echo -e "$i"
mv "$i"/"$newfile"
done

if [$# -eq 2];
then
echo "a file name has been entered"
touch $2
mv "newFile"/"$2"
mv "$2"/"$currentDir"
fi
 
Old 04-01-2003, 04:56 AM   #2
bentz
Member
 
Registered: Mar 2003
Distribution: Fedora, Mac OSX
Posts: 362

Rep: Reputation: 30
Keep in mind that your 'if' statements must be terminated. For every 'if', there must be a 'fi'.

While I'm not totally positive what you are trying to do (looks like a lot of code just to find executables), it might make the most sense to use 'find -perm +4' or '+7'. Depending on the permissions you are looking for, find can search and return a list of files with specific permissions. Check out 'man find' for more info. For a more lightweight method, you could use 'ls -l | grep rwx' (or 'r-x').
 
Old 04-02-2003, 03:47 AM   #3
roo
LQ Newbie
 
Registered: Apr 2003
Location: ireland
Posts: 2

Original Poster
Rep: Reputation: 0
thanks for that.it was mostly syntax errors in the end.
 
  


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
A really annoying wine problem amyoto Linux - Software 2 09-26-2005 11:52 AM
Totem Problem, Very Annoying jlacroix Linux - Software 1 05-13-2005 07:54 AM
Annoying IE/HTML problem jtshaw Programming 1 02-21-2004 10:29 PM
Annoying qmail problem JamesF1 Linux - Software 2 09-30-2003 06:53 AM
Very annoying problem therion12 Linux - General 2 04-05-2002 11:58 PM


All times are GMT -5. The time now is 10:58 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