[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference turris::digital_unix

Title:DIGITAL UNIX(FORMERLY KNOWN AS DEC OSF/1)
Notice:Welcome to the Digital UNIX Conference
Moderator:SMURF::DENHAM
Created:Thu Mar 16 1995
Last Modified:Fri Jun 06 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:10068
Total number of notes:35879

10017.0. "rsh nohup?" by CSC32::HEINZ () Mon Jun 02 1997 16:03

    dunix v4.0b -- rsh -- connection doesn't drop.
    
    
    customer enters this command from an ibm mainfame
    
    
    ###
    This is the command and parms we are executing on the MVS side
    
    STEP1 EXEC PGM=RS 
    PARM='/-d -l er xxx.xxx.xxx.xx nohup erloaddb.sh &'
    
    where xxx.xxx.xxx.xx is the host name
    
    
    user (er) == ksh
    erloaddb.sh == shellscript == #!/bin/ksh
    
    ###
    
    and the connection doesn't go away until the command finishes.
    
    should it?
    
    they say this works fine to an ncr box. ie: the connection drops
    
    
    is that the correct way to "submit" a job?
    
    
    
    
    thanks,
    royal
                                                    
T.RTitleUserPersonal
Name
DateLines
10017.1close stdout/stderrSAPEC3::WALLMEROTHTue Jun 03 1997 05:5011
    This is because the stdout/stderr remain open as long as the script
    is running.
    Try to redirect stdout and/or stderr indide your script; eg:
    	#!/bin/ksh
    	exec >/path/file/stdout 2>/path/file/stderr
    
    If you don't need the output, you may even close them:
    	#!/bin/ksh
    	exec >&- 2>&-
    
    Eckhardt
10017.2didn't workCSC32::HEINZTue Jun 03 1997 12:4722
    no go,
    
    on sysa i have a ksh script "/tmp/sleep"
    
    --------------------
    #!/bin/ksh
    /usr/ucb/sleep 1200 >/dev/null 2>&1
    ---------------------
    
    on sysb i enter (rsh sysa "/tmp/sleep &")
    
    i will not get the prompt back on sysb until the sleep completes.
    
    i also tried the -n option.
    
    
    i don't even know if this is supposed to work but the customer
    wants me to escalate because it works for her to an ncr system.
    
    royal
    
    
10017.3Maybe this will work?RHETT::PARKERTue Jun 03 1997 13:1819
    
    Hi, Royal. 
    
    If I change the script to look like:
    #!/bin/ksh
    /usr/ucb/sleep 1200 >/dev/null 2>&1 &
    
    Then do the rsh, I get my prompt back. The sleep continues
    until it's done without a controlling terminal :
    
     4500 ??       S        0:00.01 /usr/ucb/sleep 1200
    
    I didn't read .0 so I don't know if this is what you are trying
    to do...
    
    Hth, 
    
    Lee
    
10017.4don't alter my hintsSAPEC3::WALLMEROTHThu Jun 05 1997 05:5914
    re .1
    Your script:
    	#!/bin/ksh
    	/usr/ucb/sleep 30 >/dev/null 2>&1
    
    Doesndoesn't do what I told you.
    	#!/bin/ksh
    	exec >/dev/null 2>&1
    	/usr/ucb/sleep 1200
    
    will do it. In your version the /bin/ksh, which is waiting for the
    sleep to end, has its stdout/stderr still open.
    
    Eckhardt
10017.5Still no go w/o &RHETT::PARKERThu Jun 05 1997 10:3116
    
    Hi, Eckhardt. 
    
    That still does not work unless you put the call to sleep in
    the background like I showed in .3. Did you try it? I did. 
    
    The 2>&1 in .3 merges stderr w/ stdout but does not put the
    job in the background. I have since read .0 and this should be
    an acceptable work-around. The program they are using will need
    to take care to log any errors to a file since there is no controlling 
    terminal but that must be how it works on the NCR machine too...
    
    Hth,
    
    Lee
    
10017.6one or two & ?SAPEC3::WALLMEROTHThu Jun 05 1997 11:5113
    re .5
    hello Lee,
    
    yes I tested it with the example given in .2
    .2 has the ampersand in its rsh call:
    	(rsh sysa "/tmp/sleep &")
    and ONE ampersand should be enough.
    
    Do you really need two of them ???
    
    btw: my re.4 was meant as reply to re.2; I erronously wrote 're .1'
    
    Eckhardt
10017.7Ok, but...RHETT::PARKERThu Jun 05 1997 12:3040
    
    Hi, Eckhardt. 
    
    Well, I don't see the purpose of doing 
    
    (rsh sysa "/tmp/sleep &")
    
    Here's what happens for me :
    
    cat /tmp/junk2
    #!/bin/ksh
    exec >/dev/null 2>&1
    /usr/ucb/sleep 1200
    
    w/o the & after 1200, here is what I get :
    
    rsh sysa /tmp/junk2 &
    
    [1]  + Suspended (tty input)rsh karp3 /tmp/junk2
    
    ps(1) shows the jobs stopped:
    
    18863 ttyp4    T        0:00.00 rsh karp3 /tmp/junk2
    
    Now, if I place the & after the 1200 and use the & on the rsh line,
    
    [1]  + Suspended (tty input)rsh karp3 /tmp/junk2
    
    I do fg %1 and just get my prompt back. But, the sleep is still 
    running on sysa :
    
      769 ??       S        0:00.01 /usr/ucb/sleep 1200
    
    So, if you don't put the & on the rsh line, you will get your 
    prompt back in a few seconds and the sleep will continue on sysa. 
    
    Hth, 
    
    Lee
    
10017.8quote "" it !!!SAPEC3::WALLMEROTHThu Jun 05 1997 13:3917
    re .7
    Hi Lee,
    
    you should try to use:
    	rsh sysa "/tmp/junk2 &"
    
    The quotes are important, without them you put your rsh into background
    with them the shell started on the remote side puts the command
    /tmp/junk2 into background and that is what .1/.2 wanted to do.
    
    Putting rsh into background without using the -n flag, will stop the
    rsh immediatly in every shell with job-control.
    
    The fact, that the sleep continues to run is what we want to see.
    
    OK ?
    Eckhardt
10017.9OKRHETT::PARKERThu Jun 05 1997 13:5212
    
    Hi, Eckhardt.
    
    Ok, that works just fine. I missed the quotes. What I put in
    .3 also works fine. 
    
    Wonder what happened to Royal, the poster of .0 ?
    
    Thanks, 
    
    Lee