Linux:Program exit with displaying a print feature

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Linux:Program exit with displaying a print feature
# 1  
Old 08-24-2010
Linux:Program exit with displaying a print feature

hi All
I have a scritp running which connects to a local host and then gets a value from a field and then ftp that value to antoher server. It is running fine, and from crontab it gives the output to a file, the problem is sometime it doesnt run but if i check the output file it does not show one of the print statement which is in with in the exit loop,
Not sure where it end the loop and exit out of the script, anyhelp would be very appreciated

use IPC::Open2 ;
$wmscmd = "/opt/WMS/rel/bin/wms_tl1";
my $pid = open2(\*WMSRDR, \*WMSWTR, "$wmscmd") ;
print "Trying to Connect...\n";
while (my $junk = <WMSRDR>)
        chomp $junk ;
        print "$junk\n";
        `sleep 1`;
        last if $junk =~ /Connected to: localhost,2361/ ;
print WMSWTR "swuser\n";
print WMSWTR "wmspasswd\n";
print WMSWTR "RTRV-switch::WMS:C1::avgNoOfParties;\n";
while (my $result = <WMSRDR>)
print "RES:$result\n";
        if ($result =~ /avgNoOfParties=/)
                $temp = substr($result,18);
        last if $result =~ /avgNoOfParties=/ ;
$acp = substr($temp,0,-2);

print "AVG: $acp";  -----  the output file doesnt display this print even if it was not a succeful run
print WMSWTR "quit\n\n";

Output file: (in case of not succesful run)
Trying to Connect...
Connected to: localhost,2361

Moderator's Comments:
Mod Comment After 15 posts you should have mastered the arcane art of using CODE-tags for posting code or terminal output. I don't like having to clean up and suggest you do it yourself from now on. Thank you.

Last edited by bakunin; 08-24-2010 at 12:22 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script Works But Need It to Exit Upon Closing Program

Running Xubuntu 16.04 with shell version "GNU bash, version 4.3.48(1)-release (x86_64-pc-linux-gnu)," I have a working script that consistently renames a Chrome window: #!/bin/sh while sleep 1; do xdotool search --name chrome 2>/dev/null | while read id; do xdotool set_window --name... (21 Replies)
Discussion started by: jakefish
21 Replies

2. Shell Programming and Scripting

Exit script and open program via other user

Hello all.. so i have a problem i need to solve .. #! /bin/bash $SHELL dtterm -title my_prog -e su -user -c 'export DISPLAY=:0.0 ; /path/to/my/prog' & 2> /dev/null $SHELL intr exit This script will work on solaris 10 system in right clikt menu - in a secure system so i need to... (0 Replies)
Discussion started by: defs
0 Replies

3. UNIX for Advanced & Expert Users

Could not find the main class: Grasp. Program will exit.

I am having trouble running jgrasp. I get the message above when I try to run jgrasp. I am running fedora if that makes a difference. I have already set my environmental variable with this. Hopefully I did it right. JGRASP_HOME=/opt/jgrasp export... (0 Replies)
Discussion started by: cokedude
0 Replies

4. Shell Programming and Scripting

I dont want to exit the program by ctrl + c

Hey , guys I am new to shell programing ,, so need a help from you guys ... I have to write a shell script that accepts file name or directory name from the user if it is a directory then throw an error if it is a file then give the user two options . 1.overwrite the content 2.append the... (2 Replies)
Discussion started by: coolashu
2 Replies

5. Homework & Coursework Questions

Linux displaying content information

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: Using the fixed length field file called famous.dat make a one-line Unix command - using pipe(s) - to display an... (5 Replies)
Discussion started by: wizardoz123456
5 Replies

6. AIX

Help with AIX XL C++ complier: app exit before main program

I have two shared libraries, A, B(B depents on A, both linked with -G option which means they're rtl enable), B's toc size is bigger than 64K(-bbigtoc), while A's toc size smaller than 64K. Then I write a "Hello, world" example E, and link with A and B. Link cmd 1: xlC128_r -o E E.o -lA -lB... (0 Replies)
Discussion started by: jackliang
0 Replies

7. Shell Programming and Scripting

How to print exit status in AWK

Hi all, How can I print the exit status in AWK? echo $? doesnt work for me Thanks (4 Replies)
Discussion started by: Pauline mugisha
4 Replies

8. Shell Programming and Scripting

How to print error and exit if command fails?

Guys any tips on printing a certain error message to stderr and exiting should a command fail within a ksh script? I'm trying to null some output files. Touch isn't suitable as i need to null them. print "" > file isn't suitable as i need to check elsehere for if they are 0bytes or not. ... (5 Replies)
Discussion started by: lavascript
5 Replies

9. UNIX for Dummies Questions & Answers

EXIT from a Program not from the function..

Hi, I want a command in unix shell script which will exit my whole program, not only from the function it's using. For e.g: $1 == "m_who" && $4 == "Extrnl Vendor" { print "You don have access" exit (0); } If this error is showing on the screen, then nothing should not... (9 Replies)
Discussion started by: ronix007
9 Replies
Login or Register to Ask a Question

Featured Tech Videos