command

Executing Linux command as root in Qt

﹥>﹥吖頭↗ 提交于 2019-12-01 10:59:48
I want to execute a linux command as a root user, from my C++/Qt code. Ultimately a a dialog requesting root pass should be implemented, but for no I can hard-code root password. This is what I done so far: QProcess p; p.start( "dmidecode" ); p.waitForFinished(-1); QString p_stdout = p.readAllStandardOutput(); QString p_stderr = p.readAllStandardError(); And it is working for commands that do not request root privileges. But I want to implement commands like "zypper up" or "dmidecode" which I can't execute without a root password. Probably something can be done with void QProcess:

Why do the outputs differ when I run this code using NetBeans 6.8 and Eclipse?

无人久伴 提交于 2019-12-01 10:28:08
When I am running the following code using Eclipse and NetBeans 6.8. I want to see the available COM ports on my computer. When running in Eclipse it is returning me all available COM ports but when running it in NetBeans, it does not seem to find any ports .. public static void test(){ Enumeration lists=CommPortIdentifier.getPortIdentifiers(); System.out.println(lists.hasMoreElements()); while (lists.hasMoreElements()) { CommPortIdentifier cn=(CommPortIdentifier)lists.nextElement(); if ((CommPortIdentifier.PORT_SERIAL==cn.getPortType())) { System.out.println( "Name is serail portzzzz " + cn

Forward slash vs backward slash for file path in git bash

老子叫甜甜 提交于 2019-12-01 08:40:37
问题 I am running these two commands in Git bash . Why they behave differently? Aren't they supposed to do the same thing or am I missing something? git diff > D:\Patches\afterWGComment.txt creates file PatchesafterWGComment.txt in D:/ git diff > D:/Patches/afterWGComment.txt correctly creates file afterWGComment.txt in D:/Patches/ Note that D:/Patches/ folder is present before running the above commands. 回答1: Bash treats backslash as an escape character, meaning that the symbol following it is

Create excel file from command line

梦想与她 提交于 2019-12-01 08:20:43
is there any way to create a new excel file from command line? Thanks in advance. If the Excel files you need to create are always the same, you can create a template manually, then create new files at will with something like... copy template.xlsx myNewSpreadsheet.xlsx If you need to create files with content that varies, I suggest starting with the powershell solution proposed by David. You can do this using PowerShell: PS> $excel = New-Object -ComObject "Excel.Application" PS> $wb = $excel.Workbooks.Add() PS> $ws = $wb.ActiveSheet PS> $excel.Visible = $True < do some work > PS> $wb.SaveAs(

Smart Way to Handle Voice Commands in Code to Action a Command

偶尔善良 提交于 2019-12-01 07:44:30
问题 Rather than using Switch/Case or IF Boolean checks that can get very long and awfully tedious, I wonder if a better way can be sought for handling and processing Commands. E.G: if(settings.getName == Command) { Speak("I am here"); } if("Get News Feed" == Command) { MyRSSFeed RSSNewsFeed = new MyRSSFeed(); RSSNewsFeed.GetFeed(); } The if commands go on... Here is a snippet of my Switch Statement: switch (Command) { #region <-- Get Time Command --> case "Time Please": case "Whats the Time":

Triggering Silverlight Prism command with a keyboard shortcut

怎甘沉沦 提交于 2019-12-01 06:59:00
问题 Does anybody know whether one can trigger prism command with a shortcut? What I mean is I want to be able to define binding of a command to keyboard shortcut in declarative manner, like ClientUI does: Are there any opensource libraries for that purpose? Or maybe code samples? I found this question but I don't think that it answers mine. 回答1: I've created such gesture trigger. And I'd like to share it with you guys. Basically, it is System.Windows.Interactivity trigger which can parse gestures

Python - open new shell and run command

时光总嘲笑我的痴心妄想 提交于 2019-12-01 06:29:44
At the moment I am running a bash command from within Python using the following method: os.system(cmd) However I need to run the command in a new shell/terminal. Does anyone know how to do this? Thanks, Dan I am using the following method (this will also redirect stderr to stdout): import subprocess cmd_line = "echo Hello!" p = subprocess.Popen(cmd_line, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) out = p.communicate()[0] print out os.system() is deprecated in favour of : import subprocess print subprocess.check_output("command", shell=True) Windows "WshShell", Google it, is

The command line is too long. in java project with maven

旧街凉风 提交于 2019-12-01 06:02:20
I have maven-gwt project. It has lots of dependencies which is usual by a large project. I think it is at the limit with creation of classpath. I found some information about the limitation. Allowed is 1023 Character. But I need the libraries. I receive the following error when i want to package my project mit Maven . The command line is too long. How can I get around the problem.? Here is the expanded error in Jenkins: [INFO] --- maven-surefire-plugin:2.5:test (default-test) @ MyProject --- [INFO] Surefire report directory: C:\Documents and Settings\User\.jenkins\workspace\Myproject\target

JSF CommandButton onclick does not call Javascript function

你。 提交于 2019-12-01 05:58:27
I am using a command button from JSF. I don't know why I can't call my javascript function. NO alert will show when I click the button. <h:commandButton id="login" value="Login" action="login" onclick="return checkPasswords();" type="Submit" /> My Javascript function: function checkPasswords() { alert("test"); return false; } Check your generated code (open the page -> view source) Check your javascript console (Firefox) for errors make sure your function is callable from a normal <input type="button"> lowercase your button type. Otherwise, it should work - I have exactly the same piece of

How do I do a one way diff in Linux?

本秂侑毒 提交于 2019-12-01 05:33:18
How do I do a one way diff in Linux? Normal behavior of diff: Normally, diff will tell you all the differences between a two files. For example, it will tell you anything that is in file A that is not in file B, and will also tell you everything that is in file B, but not in file A. For example: File A contains: cat good dog one two File B contains: cat some garbage one a whole bunch of garbage something I don't want to know If I do a regular diff as follows: diff A B the output would be something like: 2c2 < good dog --- > some garbage 4c4,5 < two --- > a whole bunch of garbage > something I