The UNIX and Linux Forums  
Hello and Welcome from to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Include PERL script with in the unix shell script ganapati UNIX for Dummies Questions & Answers 1 04-29-2008 01:18 PM
How to include RETURN KEY with Background process "&" in Shell Script racbern Shell Programming and Scripting 1 03-11-2008 07:30 AM
how to include spreadsheet::ParseExcel in shell script akash Shell Programming and Scripting 1 01-10-2008 11:17 AM
How to include shell script in C program mridula High Level Programming 5 07-30-2006 04:13 AM
Difference between writing Unix Shell script and AIX Shell Scripts haroonec AIX 0 04-12-2006 03:27 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 03-17-2009
worchyld worchyld is offline
Registered User
  
 

Join Date: Mar 2009
Posts: 27
How to include shell scripts in one big shell script?

I am wanting to create one shell script which I run, as I want it to run a series of other shell scripts and PHP scripts in sequence. But, I am not sure how to include shell scripts.

Note: Paths changed for security/aesthetic reasons.

Code:
 
#!/bin/sh  
# FILE: '_final.sh' -- a list of shell scripts and php files to run. 
sh /path/to/delete.sh 
# 
# Just ignore these following lines for the moment 
#sh /path/to/mycronjobs/unzip.sh 
#php /path/to/mycronjobs/ci_cron.php --run=/cron/run/ --show-output 
#sh /path/to/mycronjobs/mysql_import.sh #php /path/to/mycronjobs/ci_cron.php --run=/cron/removeBlankRows/ --show-output
The problem is that whenever I try to run this on the command line it complains that:

Quote:
: No such file or directorynal.sh: line 4: /path/to/mycronjobs/delete.sh
I do not know why it keeps saying "directorynal.sh" for.

I've looked on Google, the most I got was that I am meant to either use the 'source' command or the '.' command, but without explanation of how to use it. I tried both of the following;

Code:
 
#!/bin/sh  
. /path/to/delete.sh 
source /path/to/delete.sh
But I still get the same result/error.

Can someone enlighten me, how do I include the shell scripts? Is there an include function or something?

Thanks.
  #2 (permalink)  
Old 03-17-2009
g.pi g.pi is offline
Registered User
  
 

Join Date: Mar 2008
Location: US
Posts: 9
Does delete.sh invoke directorynal.sh? To me, it seems like delete.sh is being called correctly.
  #3 (permalink)  
Old 03-17-2009
worchyld worchyld is offline
Registered User
  
 

Join Date: Mar 2009
Posts: 27
Quote:
Does delete.sh invoke directorynal.sh? To me, it seems like delete.sh is being called correctly.
I don't think so... I didn't even know you could invoke directorynal.sh? There's nothing in my delete.sh file that suggests this.

But then why does it complain that it can't find the file/directory/contents, even if it exists?

Delete.sh does this;

Code:
find /path/to/inbounddata/data/* -depth -type d ! -name data -ctime 24 -exec /bin/rm -Rf "{}" \;
If I try to write everything in this file, or put anything after the \; it complains that I did not use -exec properly.

I can't even use a "echo 'done'" in this file, so this is part of the reason why I've seperated them all.
  #4 (permalink)  
Old 03-17-2009
g.pi g.pi is offline
Registered User
  
 

Join Date: Mar 2008
Location: US
Posts: 9
The find command may be picking up that file. You can try this, to confirm: find /path/to/inbounddata/data/* -depth -type d ! -name data

Check if the list returned contains a file named, directorynal.sh.

If it returns a whole lot of files, redirect the output to a file.
  #5 (permalink)  
Old 03-17-2009
cfajohnson's Avatar
cfajohnson cfajohnson is offline Forum Advisor  
Shell programmer, author
  
 

Join Date: Mar 2007
Location: Toronto, Canada
Posts: 2,361

Did you write the script on a Windows box? If so, you need to remove the carriage returns (use dos2unix).
  #6 (permalink)  
Old 03-18-2009
worchyld worchyld is offline
Registered User
  
 

Join Date: Mar 2009
Posts: 27
Quote:
Did you write the script on a Windows box? If so, you need to remove the carriage returns (use dos2unix).
I used putty on a windows machine, I don't know if that is what you mean.

Quote:
The find command may be picking up that file. You can try this
I'll try that and report back...
  #7 (permalink)  
Old 03-18-2009
worchyld worchyld is offline
Registered User
  
 

Join Date: Mar 2009
Posts: 27
Hi there.

I ran:
Code:
find /path/to/inbounddata/data/* -depth -type d ! -name data
It returned:

Quote:
/path/to/inbounddata/data/2009-03-17
Which is correct, as there is only 1 folder right now.

Quote:
If it returns a whole lot of files, redirect the output to a file.
What do you mean by "redirect the output to a file", what does this do and what benefit does this have?


EDIT/UPDATE.

It appears there is an error with my delete.sh file

Code:
# It only works if I set the ctime to 0
find /path/to/inbounddata/data/* -depth -type d ! -name data -ctime 24 -exec /bin/rm -Rf "{}" \;
Quote:
# I always get this output if I set the ctime to anything but 0.
find: missing argument to `-exec'
Is there another way to resolve this problem?

Last edited by worchyld; 03-18-2009 at 08:50 AM..
Closed Thread

Bookmarks

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 01:33 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0