Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Geting prompted to Hit Enter

Status
Not open for further replies.

rabs05

MIS
Jan 30, 2015
1
US
Migrating from windows 2003 to windows 2008. When I Run my scripts I'm getting prompted to hit Enter between stops. For the life of me I cannot get why it doing it. I like this approach since I get the status query before it move onto the next service stop. Any help would be greatly appreciated. Small example of the ServerStop.cmd file.


C:\temp\e>REM @Echo .
STOP \\(ServerName) NETIQCCM () Status=STOPPED

Press ENTER key to exit...
STOP \\ServerName) NETIQmc () Status=STOPPED

Press ENTER key to exit...





Serverstop.CMD
/* Stop server NETIQ process */

SCRequest.rexx \\(Servername) Stop NETIQCCM
@SCRequest.rexx \\(Servername) Stop NETIQmc

@SCRequest.rexx \\(Servername) Stop NETIQCCM
@SCRequest.rexx \\(Servername) Stop NETIQmc

____________________________
@SCRequest.rexx

/* ************************************************************************************* */
/* Process a Request to Start, Stop or Query a Service on a remote computer. */
/* Once the request is initiated, query the service until the status changes. */
/* */
/* Requires: SC.EXE from the Win2000 Advanced Server Resource Kit */
/* */
/* ************************************************************************************* */

TRACE O

Main:

RC = 0

If RxFuncQuery('sysloadfuncs') <> 0 Then do
Call rxfuncadd 'sysloadfuncs', 'rexxutil', 'sysloadfuncs'
Call sysloadfuncs
End

Parse Arg computername command service

If Left(computername,2) not = '\\' Then Do
computername = '\\' || computername
End

computername = Translate(computername)
command = Translate(command)

If (computername > ' '),
& (command = 'START' | command = 'STOP' | command = 'QUERY'),
& (service > ' ') Then Do
NOP
End
Else Do
Say ' '
Say 'Format SCRequest.rexx \\computername command service'
Say ' command = [ START | STOP | QUERY ]'
Say ' '
Return(12)
End

If RC = 0 Then Do
RC = getServiceDisplayName(computername, command, service)
End

If RC = 0,
& (command = 'START' | command = 'STOP') Then Do
RC = executeServiceRequest(computername, command, service)
End

RC = getServiceStatus(computername, command, service)

Say ''

If RC > 0 Then Do
Say ' '
Say ' '
Do sidx = 1 to SCResults.0
Say ' =>' SCResults.sidx
End
Say ' '
End

Return(RC)

getServiceDisplayName:

computername = arg(1)
command = arg(2)
service = arg(3)

Address SYSTEM('SC' computername 'getdisplayname' '"'service'"') WITH OUTPUT STEM SCResults. ERROR STEM SCResults.
Parse var SCResults.1 with ' ' 'SUCCESS' 'Name' '=' ' ' serviceDisplayName

If Pos('FAILED',SCResults.1) > 0 Then Do
RC = 12
sStatus = 'FAILED'
End
Else Do
RC = 0
sStatus = '/'
End

Call Charout, Left(command,6) Left(computername,12) Left(service '('serviceDisplayName')',50) 'Status=' || sStatus

Return(RC)

executeServiceRequest:

computername = arg(1)
command = arg(2)
service = arg(3)

RC = 0
SCResults.0 = 0

Address System('SC' computername command '"'service'"') WITH OUTPUT STEM SCResults. ERROR STEM SCResults.

If Pos('FAILED',SCResults.1) > 0 Then Do
RC = 12
End
Else Do
RC = 0
End

Return(RC)

getServiceStatus:

computername = arg(1)
command = arg(2)
service = arg(3)
currentAttempt = 0

Do until RC = 0 | currentAttempt > 180

SCResults.0 = 0
Address SYSTEM('SC' computername 'query' '"'service'"') WITH OUTPUT STEM SCResults. ERROR STEM SCResults.

If Pos('FAILED',SCResults.1) > 0 Then Do
Return(12)
End

Do qidx = 1 to SCResults.0
If Pos('STATE',SCResults.qidx) > 0 Then Do
Parse var SCResults.qidx with ' ' 'STATE' ' ' ':' ' ' qStatusNum ' ' qStatus ' '
End
End

If (command = 'START' & qStatus = 'RUNNING'),
| (command = 'STOP' & qStatus = 'STOPPED'),
| (command = 'QUERY' & qStatus > ' ') Then Do
RC = 0
sStatus = qStatus
End
Else Do
RC = 4
Call syssleep(.50)
currentAttempt = currentAttempt + 1
sStatus = Translate(sStatus,'/\','\/')
End

Call Charout, x2c('08') || sStatus

End

Return(RC)

 
If you had used the code tgas I might have looked at your code but I am not going to indent it mentally - too much chance of getting it wrong! What happened when you activated the trace?


Nic
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top