UNIX Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsOperating SystemsUNIX Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old February 16th, 2011, 10:18 AM
fff619 fff619 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2011
Posts: 3 fff619 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 2 m 32 sec
Reputation Power: 0
Unix Script

Hi, i have got this source code



Code:
#! /bin/bash


if [ ! -d $HOME/tmp ]

then

echo tmp doesn't exist or is no directory

fi


if [ ! -d $HOME/tmp/work ]

then

echo work doesn't exist or is no directory

fi


if [ ! -e $HOME/tmp/work/* ]

then

echo work is not empty

fi


mkdir -p $HOME/tmp/work

cp $HOME/*.c $HOME/tmp/work

cd $HOME/tmp/work


i=1

for i in *.c;

do

gcc *\.c

done



but this error message appears:

./test: line 13: [: too many arguments
dokument1.c:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ at end of input
dokument2.c:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ at end of input
tx2.c:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ at end of input
dokument1.c:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ at end of input
dokument2.c:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ at end of input
tx2.c:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ at end of input
dokument1.c:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ at end of input
dokument2.c:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ at end of input
tx2.c:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ at end of input


I hope someone can help me

Reply With Quote
  #2  
Old February 16th, 2011, 01:44 PM
SimonJM SimonJM is offline
Contributing User
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Mar 2006
Posts: 2,111 SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 1 Week 1 Day 7 h 43 m 38 sec
Reputation Power: 1485
Not tested, but ... try this
Code:
#! /bin/bash

# Make sure the directory and sub-directories exist
mkdir -p $HOME/tmp/work

# Tell us if directory has something in it
count_files=$(ls -1 $HOME/tmp/work | wc -l | awk '{print $1}')
if [ $count -ne 0 ] 
then
  echo work nicht leer
fi

# Copy all .c files from home to temp directory
cp $HOME/*.c $HOME/tmp/work

# Go there and compile all .c files
cd $HOME/tmp/work
gcc *.c
__________________
The moon on the one hand, the dawn on the other:
The moon is my sister, the dawn is my brother.
The moon on my left and the dawn on my right.
My brother, good morning: my sister, good night.
-- Hilaire Belloc

Reply With Quote
  #3  
Old February 16th, 2011, 01:58 PM
fff619 fff619 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2011
Posts: 3 fff619 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 2 m 32 sec
Reputation Power: 0
EDIT: THREAD CAN BE CLOSED!

The problem was, that i just filled the copied files (the *.c files) with a right source code, but not the original files. That's why it has always overwritten the other file and the file was empty.


_________________________________

K, now i got the full source code, which is also working... but not really this great :/

Code:
#! /bin/bash

if [ ! -d $HOME/tmp ]
then
echo tmp doesn't exist or it is no directory
fi

if [ ! -d $HOME/tmp/work ]
then
echo work doesn't exist or it is no directory
fi

if [ ! -e $HOME/tmp/work/ ]
then
echo work not empty
fi

mkdir -p $HOME/tmp/work
cp $HOME/*.c $HOME/tmp/work
cd $HOME/tmp/work

for I in *.c
do
E=$(basename $I .c)
cc $I -o $E.oc
if [ -x $E.oc ]
then
echo "$E.oc is executable"
fi
done



error:

Code:
dokument1.c:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ at end of input
dokument1.oc is executable
dokument2.c:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ at end of input
dokument2.oc is executable
tx2.c:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ at end of input
tx2.oc is executable


it says it's executable, but i also says, that the *.c file has got an error

Reply With Quote
  #4  
Old February 17th, 2011, 01:29 AM
SimonJM SimonJM is offline
Contributing User
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Mar 2006
Posts: 2,111 SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 1 Week 1 Day 7 h 43 m 38 sec
Reputation Power: 1485
I don't know C, bu I'd assume those are compiler/linker errors, suggesting that there's a syntax/semantic error within your .c files.

Reply With Quote
  #5  
Old February 17th, 2011, 09:14 AM
fff619 fff619 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2011
Posts: 3 fff619 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 2 m 32 sec
Reputation Power: 0
you are right

like i said, the content of the file was something like this:

test .c file

or

this is my first .c file, which i made with the bash

...these were not my files. My teacher gave us these files, but ye... not working .c files... great!

Anyway, problem solved and everything is working fine

Thanks guys

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsUNIX Help > Unix Task

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap