1847098 Members
5105 Online
110263 Solutions
New Discussion

Re: Script issue, help!

 
SOLVED
Go to solution
Duffs
Regular Advisor

Script issue, help!

Hi,

I have a script (dell_MAN_get.sh) which calls a couple of sub-scripts and basically FTP's particular filespecs from a remote server, sorts these files accordingly (sub-script 'dell_MAN_sort.sh'), checks for rejected files before 'at'ing (rescheduling) itself again and resuming the process.

The problem I have is that the script does not get past the 'dell_MAN_sort.sh' sub-script and as such the files do not get checked for rejects or more importantly rescheduled.

I have attached the two scripts, big points to any effective helpers.

Rgds,
Dermot.
20 REPLIES 20
Duffs
Regular Advisor

Re: Script issue, help!

Hi,

........and the problemic sub-script which works corectly but does not return back to the main script.
RAC_1
Honored Contributor

Re: Script issue, help!

What does set -x gives for problematic script??
There is no substitute to HARDWORK
Duffs
Regular Advisor

Re: Script issue, help!

it doesn't give any errors, the script runs perfectly with error code 0. Something must happen upon completion of this sub-script however as nothing else within the main script gets executed afterwards??
Stephen Keane
Honored Contributor

Re: Script issue, help!

Instead of redirecting the output of the at in 'dell_MAN_sort.sh' to /dev/null try redirecting it to a file. You may find the o/s is prompting you for something at that point?
Duffs
Regular Advisor

Re: Script issue, help!

Hi Stephen,

The redirection to the /dev/null has actually been commented out of the script. I can also see from the 'set -x' that the script isn't even reaching this point.
Stephen Keane
Honored Contributor

Re: Script issue, help!

Sorry, I noticed that immediately after posting. Can you flag the line the script reaches (from your set -x output).
Duffs
Regular Advisor

Re: Script issue, help!

Stephen, yes, the 'set -x' output shows the script reaches the bottom of the dell_MAN_sort sub-script but nothing else. If you look at the subscript I even echo the "fi" at the bottom of the script, which it does.
Stephen Keane
Honored Contributor

Re: Script issue, help!

So your post "Sep 16, 2005 10:01:04 GMT" has dell_MAN_sort.sh attached - just to be clear.

Does "set -x" echo the "done" as well?

Stephen Keane
Honored Contributor

Re: Script issue, help!

Worth putting

#!/bin/sh

at the beginning of del_MAN_sort.sh perhaps? Or whatever shell you want to run it under.
Duffs
Regular Advisor

Re: Script issue, help!

Yes thats correct.

It echo's the done also plus I have included an exit 1 in an attempt it force it to revert back to the main script but this doesn't work either.

I have actually included the shell (#!/bin/sh) atthe beginning of the script also but simply haven't included this in my attachment, apologies about that.

D.
Stephen Keane
Honored Contributor

Re: Script issue, help!

So you get the "done" message, but not the output of "$?" etc? And then the "main" script stops? Or am I misunderstanding?

Stephen Keane
Honored Contributor
Solution

Re: Script issue, help!

Also, when you call dell_MAN_sort.sh from the "main" script have you tried calling it thus

/sbin/sh -x $SCRIPTDIR/dell_MAN_sort.sh

Just as a matter of interest...
Duffs
Regular Advisor

Re: Script issue, help!

Stephen, yes that is exactly what is happening.

I haven't actually called the subscript from the main script in that exact format but I'll give to a go.....
Patrick Wallek
Honored Contributor

Re: Script issue, help!

Can you post a complete run of the scripts with the "-x' debug option set for both?

Everything looks correct, but seeing the debug output would be helpful.
john korterman
Honored Contributor

Re: Script issue, help!

Hi,

it may not help, but try changing the line

for FILENAME in [ `cat $SRCDIR/man_files` ]; do

to

for FILENAME in $(cat $SRCDIR/man_files); do

as I think the shell will regard the brackets as file names...
Does man_files contain only plain files?

regards,
John K.
it would be nice if you always got a second chance
Duffs
Regular Advisor

Re: Script issue, help!

John, thanks for your suggestion but unfortunately that didn't help on this occasion. The host that is running the script is currently down for maintanence and as I am out of the office on Monday I will be happy to try these any further suggestions for this on Tuesday.

Patrick, I will gladly forward you the debug for this on Tuesday.

Stephen, I will also look forward to calling the subscript in the manner you suggested.

Thanks,
Dermot
Sandman!
Honored Contributor

Re: Script issue, help!

Dermot,

IMHO, the shell is getting confused between command substitution and test command syntax i.e.

>> for FILENAME in [ `cat $SRCDIR/man_files` ]; do <<

The above command will set the variable FILENAME to the name of the files in the $SRCDIR punctuated by brackets. Change the above for loop to:

>> for FILENAME in `cat $SRCDIR/man_files` ; do <<
OR
>> for FILENAME in $(cat $SRCDIR/man_files) ; do <<

hope it helps!!!
john korterman
Honored Contributor

Re: Script issue, help!

Hi again Dermot,

could you please show us what dell_file_check.sh does?

and perhaps make an "ls -l" on the the list of files in $SRCDIR/man_files?


regards,
John K.
it would be nice if you always got a second chance
Muthukumar_5
Honored Contributor

Re: Script issue, help!

I am recommending you to make a single script. It will reduce the confusion and time.

Just change script as functions in the same script.

Like,

sort()
{
}
reject()
{
}

If you are not sure then attach all relavent scripts to your requirement here. It will give an opportunity to give quick and effective solution.

hth.
Easy to suggest when don't know about the problem!
Duffs
Regular Advisor

Re: Script issue, help!

Hi,

Stephen, you're suggestion hit the nail on the head, I needed to call the subscript by opening the shell first of all.

Thanks again!