Retrying a remote connection after failure

Hi all,

I am new to this forum and want an urgent help from you experts. I am currently using SunOs 5.10.

I have a .cfi file which contains some commands to be executed in a node(MSC node in telecom) To connect to a node (for eg node name is MSC1) we have a shell script that has the following command

/bin/cfi -F /home/scriptdt/scr/script/file.cfi -N MSC1 > outputfile

(cfi utility is invoked from /bin, -F option followed by the path of file.cfi which contains the commands, -N connects to the network element MSC1 and the o/p is stored in outputfile)

there are many lines like this for connecting into different nodes in the script file.

Now the trouble is sometimes due to network issues the connection to the nodes(MSC1 in this case) is not obtained and the execution moves into the next line in the script.So that particular node is missed and results in missing data. I want to retry to the node after some time when all the lines have been performed.

there is an option -b in cfi help list (tries after a delay) but the problem is if i use -b option it gets stuck onto that particular line/Node only and does not proceed to other commands until the connection is obtained and the work is done.

Please help me out how to come out of this situation urgently. I am a newbie to shell scripting.

---------- Post updated at 10:22 AM ---------- Previous update was at 10:03 AM ----------

any help?

Bumping up threads is not allowed by the forum rules. Also check this:

Everyone at the UNIX and Linux Forums gives their best effort to reply to all questions in a timely manner. For this reason, posting questions with subjects like "Urgent!" or "Emergency" and demanding a fast reply are not permitted in the regular forums.

For members who want a higher visibility to their questions, we suggest you post in the Emergency UNIX and Linux Support Forum. This forum is given a higher priority than our regular forums.

Posting a new question in the Emergency UNIX and Linux Support Forum requires forum Bits. We monitor this forum to help people with emergencies, but we do not not guarantee response time or best answers. However, we will treat your post with a higher priority and give our best efforts to help you.

If you have posted a question in the regular forum with a subject "Urgent" "Emergency" or similar idea, we will, more-than-likely, close your thread and post this reply, redirecting you to the proper forum.

Of course, you can always post a descriptive subject text, remove words like "Urgent" etc. (from your subject and post) and post in the regular forums at any time.

Thank you.

The UNIX and Linux Forums

Hi Mods,

Thanks for diverting me to the correct thread. However I haven't used urgent or emergency words in the title of the thread.

Being new it will take me few days to get used to this highly valuable forum.

Thanks.
Regards :o

You did not use in the subject but in your post:

and as the reminder says

Also bumping the thread up after some minutes (if I got the time right), just because no answer was there already, fits to the "urgent" :wink:

Anyway I think you got the message. No problem - keep the Forum Rules in mind and happy posting :slight_smile:

I tried to find some documentation about CFI and the cfi binary, but no success. It maybe apply unix return codes where:

  • Return Code = 0 -> Success
  • Return Code != 0 -> Fail

So you can try this:

execCFI ()
{
	cfiScript="${1}"
	cfiRunNode="${2}"
	
	# Default number of retries is 5
	numRetries="${3:-5}"
	
	if [ ! -f "${cfiScript}" ]
	then
		echo "ERROR: CFI script is not a valid file: [${cfiScript}]."
		return 1
	fi

	currDateTime=`date +"%Y%m%d-%H%M%S"`
	cfiOutFile=`basename "${cfiScript}"`
	cfiOutputFile="${cfiOutFile}_${currDateTime}"
	
	cfiReturnCode=1
	
	while [ ${cfiReturnCode} -ne 0 -o ${numRetries} -ge 0 ]
	do
		/bin/cfi -F "${cfiScript}" -N "${cfiRunNode}" 1>"${cfiOutputFile}" 2>&1
		cfiReturnCode=${?}
		numRetries=`expr ${numRetries} - 1`
	done
        return ${cfiReturnCode}
}

execCFI "/home/scriptdt/scr/script/file.cfi" "MSC1" "5"
execCFIRetCode=${?}

if [ ${execCFIRetCode} -ne 0 ]
then
         echo "ERROR: Failed to execute node: [MSC1]."
fi

I hope it helps.

Regards.

Hi,

Thanks for the reply. I got the work around.

CFI is a utility developed by my employer company and used internally , that is why it can't be found over the net.

Thanks anyways :slight_smile: