INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Geting prompted to Hit Enter

Geting prompted to Hit Enter

(OP)
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)

RE: Geting prompted to Hit Enter

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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close