console-application

Use wc on all subdirectories to count the sum of lines

自古美人都是妖i 提交于 2019-11-30 02:43:07
How can I count all lines of all files in all subdirectories with wc ? cd mydir wc -l * .. 11723 total man wc suggests wc -l --files0-from=- , but I do not know how to generate the list of all files as NUL-terminated names find . -print | wc -l --files0-from=- did not work. You probably want this: find . -type f -print0 | wc -l --files0-from=- If you only want the total number of lines, you could use find . -type f -exec cat {} + | wc -l Perhaps you are looking for exec option of find . find . -type f -exec wc -l {} \; | awk '{total += $1} END {print total}' To count all lines for specific

standard way to perform a clean shutdown with Boost.Asio

∥☆過路亽.° 提交于 2019-11-30 02:36:25
I'm writing a cross-platform server program in C++ using Boost.Asio. Following the HTTP Server example on this page, I'd like to handle a user termination request without using implementation-specific APIs. I've initially attempted to use the standard C signal library, but have been unable to find a design pattern suitable for Asio. The Windows example's design seems to resemble the signal library closest, but there's a race condition where the console ctrl handler could be called after the server object has been destroyed. I'm trying to avoid undefined behavior as specified by the C++

Getting WebBrowser Control To Work In Console Application?

蹲街弑〆低调 提交于 2019-11-30 02:25:56
问题 I have a printer class that is capable of printing HTML via the WebBrowser object. I want to be able to print from a console application, but I get an error when my printer class tries to create a WebBrowser object: WebBrowser browser = new WebBrowser(); Error: ActiveX control '8856f961-340a-11d0-a96b-00c04fd705a2' cannot be instantiated because the current thread is not in a single-threaded apartment. I tried adding a reference to System.Windows.Forms into my console application but that

Multiple consoles for a single application C++

℡╲_俬逩灬. 提交于 2019-11-30 02:24:08
Is it possible to create two console windows (one being the main) and the secondary being a pop-up like a message box in Windows Forms? I only want the secondary console window to hold IDs (that will be hard coded into the application) So the user does not have to keep returning to the main menu to check available IDs If so how would you go about it? Many Thanks Yes, you can do it. The solution is actually very simple - our process can start a new helper child-process, so the helper process will display whatever our process sends it. We can easily implement such a solution with pipes: for each

How to execute child console programs without showing the console window from the Win32 GUI program?

亡梦爱人 提交于 2019-11-30 01:56:14
问题 (I've searched SO answers and found no clear solution to this problem.) I'm working on a MFC GUI program. This program runs various child programs including console program and shell command script(.cmd). Initially it displayed one GUI window and one console window (created with AllocConsole ) because there are many console output from the child processes. But many users complained about the console window so we decided to hide the console window. Firstly tried like below: if (AllocConsole())

Load Assembly in New AppDomain without loading it in Parent AppDomain

╄→гoц情女王★ 提交于 2019-11-30 01:54:21
I am attempting to load a dll into a console app and then unload it and delete the file completely. The problem I am having is that the act of loading the dll in its own AppDomain creates a reference in the Parent AppDomain thus not allowing me to destroy the dll file unless I totally shut down the program. Any thoughts on making this code work? string fileLocation = @"C:\Collector.dll"; AppDomain domain = AppDomain.CreateDomain(fileLocation); domain.Load(@"Services.Collector"); AppDomain.Unload(domain); BTW I have also tried this code with no luck either string fileLocation = @"C:\Collector

How to cleanly shut down a console app started with Process.Start?

坚强是说给别人听的谎言 提交于 2019-11-30 01:51:45
This is looking like an impossible task. Absolutely nothing I've found works. The question is how to cleanly close a console application started with Process.Start that has been started with no console window and without using shell execute: ( ProcessStartInfo.CreateNoWindow = true; ProcessStartInfo.UseShellExecute = false; ). It is given that the application being started will shut down "cleanly" if it receives a ctrl-c or ctrl-break signal, but there seems to be no way to send it one that works (particularly GenerateConsoleCtrlEvent). Process.Kill doesn't work. It leaves corrupt files behind

Is it possible to build a Console app that does not display a console Window when double-clicked?

我与影子孤独终老i 提交于 2019-11-30 01:50:11
Related: Should I include a command line mode in my applications? How to grab parent process standard output? Can a console application detect if it has been run from Explorer? I want to build a console app, that is normally run from the command line. But, when it is double clicked from within Explorer (as opposed to being run from a cmd.exe prompt) then I'd like the program to NOT display a console window. I want to avoid this: Is it possible? EDIT I guess another way to ask it is, is it possible for a program to know how it was invoked - whether by double-click or by command line ? I'm

Impersonate with username and password?

五迷三道 提交于 2019-11-30 00:46:17
WindowsIdentity identity = new WindowsIdentity(accessToken); WindowsImpersonationContext context = identity.Impersonate(); ... context.Undo(); Where do i declare a administraotr UserName and Passowrd ? the accessToken param doesn't help me too much... Do I have to import DLL'S for it ? Stefan You need to get the user's token. Use the p/invoke LogonUser from the advapi32.dll: [DllImport("advapi32.dll", SetLastError = true)] public static extern bool LogonUser( string lpszUsername, string lpszDomain, string lpszPassword, int dwLogonType, int dwLogonProvider, out IntPtr phToken); Example: IntPtr

Upload videos to my Youtube channel without user authentication using YoutubeApi v3 and ouath2

限于喜欢 提交于 2019-11-30 00:32:30
The goal of my task is to create a console script, which will insert recently uploaded videos on my own site to my own Youtube channel. I want to use server-to-server authentication but YoutubeApi does not support this way of authentication now. So my question is: How could I upload video to youtube channel, using oauth2 authentication with console script without any help of a user? Is there any way to do this without using deprecated ClientLogin authentication protocol? Yes this segment explains how to: https://developers.google.com/youtube/v3/guides/moving_to_oauth#standalone Basically, you