delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2017/08/02/19:41:12

X-Recipient: archive-cygwin AT delorie DOT com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:to:from:subject:date:message-id:references
:mime-version:content-type; q=dns; s=default; b=V69dHiYCTzV+PeCz
LiJZSr1qKGAI9HS6qaoND/SAI19RNiuV+v4RxcNET0Tp+/WgCsom1dSx6R7GTTmR
iFghTPv0cNdKhx2bAnK/63RIFNfD82956PFJLFNBthxCwgNvfAcg8OypfgoNj7ZK
9dCY9UkwrxpjsqHxwrjRbr0Np7A=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:to:from:subject:date:message-id:references
:mime-version:content-type; s=default; bh=PLFtTKYIFrN3q4KXWcGZlz
1QDVs=; b=Ojix6oe7o8eLvUpkj/Ry4awnl/+RSrvFNCK+3gEHs/63op0DZTh77D
NULDMvCwQcE3AVL346rDjD03t+g/5W0P6N2lci+6rlXnQyOLTViGFiqdxuUc6nn0
R6lxR2+Gi+xvRCyGBynyCFz30YYZ6DvzO4JhIl4ygRf/zPmQNptXU=
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
Authentication-Results: sourceware.org; auth=none
X-Virus-Found: No
X-Spam-SWARE-Status: No, score=-0.1 required=5.0 tests=BAYES_00,FREEMAIL_FROM,KAM_LAZY_DOMAIN_SECURITY,KAM_OTHER_BAD_TLD autolearn=no version=3.3.2 spammy=Win, 1.3.4-2, stealing, keyboard
X-HELO: blaine.gmane.org
To: cygwin AT cygwin DOT com
From: Oleksandr Gavenko <gavenkoa AT gmail DOT com>
Subject: Re: Hiding console when running Cygwin utility from Task Scheduler.
Date: Thu, 03 Aug 2017 02:40:45 +0300
Lines: 71
Message-ID: <8660e5wnb6.fsf@gavenkoa.example.com>
References: <86o9ryymx5 DOT fsf AT gavenkoa DOT example DOT com> <a547973c-5175-9dc8-1b8a-55635e73983b AT SystematicSw DOT ab DOT ca>
Mime-Version: 1.0
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (windows-nt)
X-IsSubscribed: yes

On 2017-08-02, Brian Inglis wrote:

> Redirect all stdin from /dev/null, stdout, stderr to a log file in your script ,
> like:
> 	#!/bin/bash
> 	prog=${0##*/}
> 	base=${prog%.*}
> 	log=/var/log/$base.log
>
> 	# do everything inside this wrapper
> 	{
> 		...
> 	} < /dev/null &> $log
>
> or equivalent on each command if you don't have many.

That is not the case for:

> How can I prevent console to be shown when bash started from Task Scheduler?

Closing of stdin / stdout / stderr is task for external process (like CRON)
even on UNIX.

With simple:

  #include <stdio.h>
  #include <unistd.h>

  int main(int argc, char **argv) {
      fclose(stdin);
      fclose(stdout);
      fclose(stderr);

      sleep(10);

      return 0;
  }

in Task Scheduler I see console window and supporting conhost.exe process.

OK. I know about run.exe from package:

  run
  sdesc: "Launch cmdline programs with hidden console"
  ldesc: "Launch cmdline programs with hidden console"
  category: Base
  requires: cygwin
  version: 1.3.4-2

I tried:

  $ cp /bin/run.exe ~/usr/bin/runbash.exe

and provide path to ~/usr/bin/runbash.exe in Task Scheduler. Console window
still flashes.

With my tiny test utility:

  $ cp /bin/run.exe ~/usr/bin/runxtest.exe

it flashes too from Task Scheduler but for a moment not 10 sec ))

Same if I run by Win+R:

  $ run xtest

My goal to avoid any splashes on screen and possible keyboard focus stealing
from sudden task execution.

-- 
http://defun.work/


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

- Raw text -


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