Sponsored Content
Top Forums Shell Programming and Scripting Linux:Program exit with displaying a print feature Post 302447813 by imran721 on Tuesday 24th of August 2010 11:14:52 AM
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

Code:
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";
sleep(3);
print WMSWTR "RTRV-switch::WMS:C1::avgNoOfParties;\n";
while (my $result = <WMSRDR>)
        {
push(@LIST,$result);
print "RES:$result\n";
        if ($result =~ /avgNoOfParties=/)
                {
                $temp = substr($result,18);
                }
        last if $result =~ /avgNoOfParties=/ ;
        }
chomp($temp);
$acp = substr($temp,0,-2);
 

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

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..
 

9 More Discussions You Might Find Interesting

1. 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

2. 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

3. 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

4. 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

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. 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

7. 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

8. 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

9. 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
ypxfr(1M)						  System Administration Commands						 ypxfr(1M)

NAME
ypxfr, ypxfr_1perday, ypxfr_1perhour, ypxfr_2perday - transfer NIS map from a NIS server to host SYNOPSIS
/usr/lib/netsvc/yp/ypxfr [-c] [-f] [ -C tid prog server] [-d ypdomain] [-h host] [-s ypdomain] mapname DESCRIPTION
The ypxfr command moves an NIS map in the default domain for the local host to the local host by making use of normal NIS services. It creates a temporary map in the directory /var/yp/ypdomain (this directory must already exist; ypdomain is the default domain for the local host), fills it by enumerating the map's entries, fetches the map parameters (master and order number), and loads them. It then deletes any old versions of the map and moves the temporary map to the real name. If run interactively, ypxfr writes its output to the terminal. However, if it is started without a controlling terminal, and if the log file /var/yp/ypxfr.log exists, it appends all its output to that file. Since ypxfr is most often run from the privileged user's crontab file, or by ypserv, the log file can retain a record of what was attempted, and what the results were. For consistency between servers, ypxfr should be run periodically for every map in the NIS data base. Different maps change at different rates: a map might not change for months at a time, for instance, and can therefore be checked only once a day. Some maps might change sev- eral times per day. In such a case, you might want to check hourly for updates. A crontab(1) entry can be used to automatically perform periodic updates. Rather than having a separate crontab entry for each map, you can group commands to update several maps in a shell script. Examples (mnemonically named) are in /usr/sbin/yp: ypxfr_1perday, ypxfr_2perday, and ypxfr_1perhour. Refer to ypfiles(4) for an overview of the NIS name service. OPTIONS
-c Do not send a "Clear current map" request to the local ypserv process. Use this flag if ypserv is not running locally at the time you are running ypxfr. Otherwise, ypxfr complains that it cannot communicate with the local ypserv, and the transfer fails. -f Force the transfer to occur even if the version at the master is not more recent than the local version. -C tid prog server This option is for use only by ypserv. When ypserv starts ypxfr, it specifies that ypxfr should call back a yppush process at the host server, registered as program number prog, and waiting for a response to transaction tid. -d ypdomain Specify a domain other than the default domain. -h host Get the map from host, regardless of the master. If host is not specified, ypxfr asks the NIS service for the name of the master, and tries to get the map from there. host must be a valid host name. -s ypdomain Specify a source domain from which to transfer a map that should be the same across domains. FILES
/var/yp/ypxfr.log Log file /usr/lib/netsvc/yp/ypxfr_1perday Script to run one transfer per day, for use with cron(1M) /usr/lib/netsvc/yp/ypxfr_2perday Script to run two transfer per day, for use with cron(1M) /usr/lib/netsvc/yp/ypxfr_1perhour Script for hourly transfers of volatile maps /var/yp/ypdomain NIS domain /usr/spool/cron/crontabs/root Privileged user's crontab file ATTRIBUTES
See attributes(5) for descriptions of the following attributes: ypxfr Only +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWnisu | +-----------------------------+-----------------------------+ ypxfr_1perday, ypxfr_1perhour, and ypxfr_2perday +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWypu | +-----------------------------+-----------------------------+ SEE ALSO
crontab(1), cron(1M), ypinit(1M), yppush(1M), ypserv(1M), ypfiles(4), attributes(5) SunOS 5.10 11 Mar 1998 ypxfr(1M)
All times are GMT -4. The time now is 05:53 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy