delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2008/03/13/01:10:32

X-Recipient: archive-cygwin AT delorie DOT com
X-Spam-Check-By: sourceware.org
Message-ID: <16021741.post@talk.nabble.com>
Date: Wed, 12 Mar 2008 23:09:46 -0700 (PDT)
From: nlian <norliansyah AT gmail DOT com>
To: cygwin AT cygwin DOT com
Subject: How to capture error in Cygwin, $? is not working
MIME-Version: 1.0
X-Nabble-From: norliansyah AT gmail DOT com
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

Hi,

I want to write a simple script to start and stop windows service remotely.
Here is the script:

#!/usr/bin/bash
sc \\\\servername start "MyService"
echo $?

=======
The above script return the following messages: 
[SC] StartService: OpenService FAILED 1060:

The specified service does not exist as an installed service.

0
=======

What I don't understand is why $? return 0 and not 1060 or any other
error code. I want to capture the error code returned from windows program
How to do this in Cygwin? Please advise.


Thanks.
-- 
View this message in context: http://www.nabble.com/How-to-capture-error-in-Cygwin%2C-%24--is-not-working-tp16021741p16021741.html
Sent from the Cygwin list mailing list archive at Nabble.com.


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019