w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Code runs fine in xcode, but errors out on the command line
You forgot to #include <string> xcode could have it indirectly included from <iostream> but it's not mandated, so just include it yourself to play it safe.

Categories : C++

awk command runs fine until "backticks" are inserted
Well, after more digging and toying around, I found out that I can just encompass the whole target of the mv command in quotes and then just remove the backslashes. But then I came up with a different problem. It was saying that the target for the mv command wasn't a directory. I KNOW it isn't a directory... I'm trying to rename some files here... (grumble, grumble) mv: target 'Showname - S01E01.avi' is not a directory Anyway, after more googling I found out on a LinuxQuestions post that this is apparently due to the spaces in the filename. I was able to fix that by adding the following to the beginning of my script. IFS=' ' Now it renames my files to a decent naming scheme so other programs/services can pick up on them and add them properly

Categories : Bash

Command.ExecuteScalar always return null while Stored Procedure in Management Studio runs fine
The problem is in the way you return data. If you want to use ExecuteScalar, you should not RETURN but instead simply SELECT. Try to change the SP as following: CREATE PROCEDURE [dbo].[spCanUserEdit] ( @username nvarchar(255) ) AS BEGIN SET NOCOUNT ON; DECLARE @CanEdit bit SELECT @CanEdit = CanUserEdit FROM tblUsers WHERE username = LOWER(@username) SELECT @CanEdit RETURN 0 END GO If you can't change the SP, but the code, the solution is to read parameter '@ReturnValue' with ExecuteNonQuery.

Categories : C#

php sudo shell_exec command runs from command line, but not from browser
Would it be out of the question to make a shell script that would run your command? #!/bin/sh sudo whoami in the php: $retVal = `/path/to/custom/script/myscript.sh &2>1`; if ($retVal) echo 'SWEET'; else echo 'POOP: ' . $retVal; {command} inside `` means the same as shell_exec('{command}') on a linux server. If I'm not way off base here your goal is to add users to your VPN (among other things perhaps) in which case you could pass command-line parameters for username/password/etc to your custom shell script. It's not exactly a pure shell_exec() answer to your question, but maybe you can run myscript.sh without doing sudo. Just basing this on the fact you said everything you tried worked in shell and path was set in echo $PATH, but not sudo echo $PATH in your PHP script. Seem

Categories : PHP

Error in Heroku does not make sense, application runs fine locally. RecordNotFound
I suppose you have to handle ActiveRecord::RecordNotFound error: def current_cart if session[:cart_id] begin @current_cart ||= Cart.find(session[:cart_id]) session[:cart_id] = nil if @current_cart.purchased_at rescue ActiveRecord::RecordNotFound => e create_cart end else create_cart end @current_cart end def create_cart @current_cart = Cart.create! session[:cart_id] = @current_cart.id end This could be caused by invalid session data.

Categories : Ruby On Rails

Command line script that runs a method only when it is executed?
Finally figured this out. Instead of running MyApp:initialize in lib/myapp.rb I put it in the bin/myapp file. This ensures that it is only run when the app is run from the command line and not when being tested via Rake or required by another script.

Categories : Ruby

Script working fine from command line, but not from crontab
Take a look at /apps/ins/.profile and the files it executes - such files usually have a conditional that exits the script early if it's not run in a terminal. For example: [ -z "$PS1" ] && return This may change the behavior of your script (or even skip it, if exit is used in place of return). At the very least, you will miss aliases, possible PATH changes, and other things set up in the .profile script, which will affect if and how your main script is run. Try to comment the line . /apps/ins/.profile in the script above, and see if it still runs in the terminal. If it does, run it like that from crontab and see if it fixes your problem.

Categories : Linux

python script runs from command line but using subprocess gives error
When using subprocess.Popen() the first argument should be a list with a separate entry for each argument to the process you want to run: run=subprocess.Popen([sys.executable, 'maps2.py', '-i=/media/babak/LaCie/necessary/visualisation/CMIP3_Babak/Temperature/bccr_bcm2_0', '-o=temp/CMIP3', '-p=temp_001' ]) What you currently have would be the equivalent to running the following on the command line: python 'maps2.py -i=/media/babak/LaCie/necessary/visualisation/CMIP3_Babak/Temperature/bccr_bcm2_0 -o=temp/CMIP3 -p=temp_001'

Categories : Python

VS2012 link.exe runs from command line, but not from C#'s System.Diagnostics.Process?
I'd imagine this is down to the working directory, when you call the process from your applicaton, the working directory used is derived from wherever the application was started from, i.e bin/debug. The commandline will most likely be opening it from its native location where the dll also lives. Therefore your application will be looking in bin/debug for the dll instead of the correct directory You can set the working directory to the correct directory through ProcessStartInfo... var linkerPath = Path.Combine( Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86), "\Microsoft Visual Studio 11.0\VC\bin\link.exe"); ProcessStartInfo startInfo = new ProcessStartInfo { FileName = linkerPath, WorkingDirectory = Path.GetDirectoryName(linkerPath)}; Proc

Categories : C#

Bash script runs from successfully from command line but not when invoked by program
Following on the suggestion by @John3136, try putting the full path to aptbatch.sh, e.g. /home/scripts/aptbatch.sh, instead of just the name. If it's not in the $PATH of whatever shell is executing the script, it won't be found.

Categories : Bash

python program works fine from command line and as git difftool, but dies as external-diff
Thanks for the tip, @ThomasFenzl, indeed git was running python 2.7.2 while from the command line it is running 2.7.5. Still not completely sure why it can't find the ipdb lib dir, but it was a good starting point for sure. Apparently the use of #!/usr/bin/env python as opposed to specifying the exact python binary path (which on my system is the canonical /usr/local/bin/python) causes it when run from git to grab the system's original python. I think I still need to fall back to the /usr/bin/env python method though because one of the environments I need this on only has python installed in my user directory.

Categories : Python

Class wont run in Jar but runs fine from Netbeans
It's probably a dependency issue when you are trying to run the executable jar. There are a number of maven (assuming you're using maven with Netbeans since that's the normal use case these days) plugins for bundling the dependency jars with the executable jar. Try this from the command line instead of java -jar to help you debug: mvn exec:java -Dexec.mainClass="com.example.Main" [-Dexec.args="argument1"] ...

Categories : Java

How can I get an MFC application to block from the command line?
You can't. EXEs are marked as either console or windows programs and if it's a Windows program control is handed over to the Windows manager and the console will keep running. Your best bet is to create a small console app that calls CreateProcess to launch the Windows app and then simply WaitForSingleObject on the hProcess handle for it to finish. More technical information on why it's not possible is available on the The Old New Thing blog here: http://blogs.msdn.com/b/oldnewthing/archive/2009/01/01/9259142.aspx

Categories : C++

IE Doesn't run remote JS properly but local runs fine
Change window.onresize = init(); to window.onresize = init; As it stands, the init() is trying to run immediately when the JS file is loaded, which is throwing the error because the DOM hasn't loaded yet.

Categories : Javascript

Script runs fine in the browser console, but not online
it's hard to say without seeing your code, but is there a chance that your script is being executed before your entire page is loaded (or, more specifically, before the element with id #menu-item-34 has been added to the DOM)? Try wrapping your script inside a function, and then setting that function as your page's onload handler: window.onload = function() { /* code goes here */ };

Categories : Javascript

Everything white in OpenGl, same code runs fine on another machine
Well, here's the problem: GLfloat especularidade[COORDHOMO] = {10.0, 10.0, 10.0, 1.0};//<------here GLint especMaterial = 6000; glMaterialfv(GL_FRONT, GL_SPECULAR, especularidade); /* Define a concentração do brilho sobre os objetos */ glMateriali(GL_FRONT, GL_SHININESS, especMaterial); specular color is the same as every other color. Every component is supposed to be within 0.0..1.0 range if you use floats. Also it is possible that shininess is also too high, it is supposed to be within 0..128.0 range, and I'd definitely use float there glMaterialf(GL_FRONT, GL_SHININESS, 25.0) or something. Either your notebook or your desktop computer has non-compliant OpenGL driver. Fixed-function OPenGL is supposed to clamp results of lighting calculations to 0.0..1.0 range (which is th

Categories : Opengl

Why this CTE expression hangs while temp table runs fine
I recently had a (possibly related) situation where a complex query with a CTE would give inconsistent results, depending on which parameters were supplied. For example: First Test: Restart SQL Server Run the query with parameter A, get an answer in < 1s; Run the query with parameter B, get an answer in < 1s; Second Test: Restart SQL Server Run the query with parameter B, get an answer in 64s; Run the query with parameter A, get an answer in 64s; Turned out that query plan generated for "A" was efficient, while that generated for "B" was not; since query plans are cached, the first query run after the restart of the server controlled performance of all the queries. Solution was to force a rebuild of statistics for the database.

Categories : SQL

Retrieving command line arguments in a Qt application
code should be argv[1]... int main(int argc, char *argv[]) { QApplication a(argc, argv); MainWindow w; w.show(); w.setGeometry(QRect(QPoint(100,100), QSize(1000,500))); CHat *hat = new CHat(); hat->color(argv[1]);//"red" ???? --> argv[1] return a.exec(); } this works for the commandLine: ./countHats "red" or ./countHats red

Categories : C++

Write to command line if application is executed from cmd
This all depends on what the exe type is - which is a flag in the PE-header (the "exe" shell): if it is flagged as a windows app, it doesn't get a console / output to the existing console - regardless of how it is started if it is flagged as a console app, it does get a console / output to the existing console - regardless of how it is started It cannot be both. It you want it to work like a windows exe normally, then you will have to compile it as a windows exe, which means no: it won't write to the console normally. Trying to acquire access to the console from a windows exe is tricky, and would require P/Invoke to the OS. If it is flagged as a console exe, then just Console.WriteLine will work fine.

Categories : C#

How to write a an OSGI command-line application
To answer my own question (Q&A style): I currently believe would be best to start OSGI embedded (clean) start the container export API package (org.osgi.framework.system.packages.extra) install and start the required bundles consume services outside of OSGI shutdown the container exit the app After all bundles are started it's safe to assume the required services are available. This also avoids passing configuration into OSGI that's actually only arguments to a service invocation.

Categories : Java

Thread Management in OSX Command Line C Application
# Somehow put main thread to sleep here… CFRunLoopRun(); There you go. CFRunLoopRun() spins the run loop for the current thread (in this case, the main thread). Since you’ve attached an FS event stream to the main run loop, your FS events will be processed by this run loop and, consequently, your callback function will be called. The run loop will keep spinning until you call CFRunLoopStop() (if you call it). You need to decide how to handle program termination, though. Cocoa applications can use the convenient -[NSApplicationDelete willTerminate:] method to perform cleanup operations. Since you are not using Cocoa, you’ll have to roll your own, maybe by using atexit(3) or signal(3) and using ⌃C to quit the program.

Categories : C

C# Console Application Does NOT read from the command line, as it should
Your code seems to be okay. You're probably not passing the argument properly. Take the following steps: Right-Click on your Project => Properties => Debug => insert "Pleasework" into the command line arguments => save and debug your code step-by-step. And you'll see:

Categories : C#

Dojo treegrid runs fine locally, but not on remote server
The Sorry, an error occurred message is a result of a problem with your store and usually the data you are putting into the store. The message is shown in DataGrid._onFetchError and TreeGrid mixes in the DataGrid. You can put a break point on the query engine of what ever store you are using, analyze the data being passed into the store

Categories : Database

MYSQL error message when running through php but runs fine through DQ query
Change if(!$result = $db->query(query2)){ to if(!$result = $db->query($query2)){ ^ $ is missing in front of $query2 variable On a side note: your code in its current state is prone to sql-injections. Please consider using prepared statements.

Categories : PHP

OpenCV Build ok, debug throws error, runs fine from .exe
Do you get the unhandled exception before main? If not, then your code is somehow doing something to raise the exception. Put a breakpoint on the first line, then hit F5, then once at the breakpoint, step through the code one line at a time to see which one causes the exception, F10 key to do this. My gut feeling is that when running from the debugger, the cv::imread is failing since it is not finding the img1.jpg from the expected location, the current working directory is that of the solution file, not of the debug output build dir. You can do a quick test and copy the img1.jpg to the dir containing the sln file and see if that fixes the problem.

Categories : C++

How to query running java application from command line?
Your program can use the attach API to locate the running JVM and connect to it. http://docs.oracle.com/javase/7/docs/jdk/api/attach/spec/ Then you can tell it to load an agent into the JVM. See the java.lang.instrument package description, chapter “Starting Agents After VM Startup” to see how such an agent can be implemented. This agent can call the desired method in the target JVM. Note that there already exists the JMX agent for a lot of operations you might want to perform when dealing with managing another application. It’s worth studying it.

Categories : Java

Shell script call command line application
You can use echo, but in a pipeline. echo 1000 | java myProgram If you want to send a file, you can use cat: cat file.txt | java myProgram

Categories : Java

How to get command line arguments of an Eclipse 4 application from code
I've got it. It is not so intuitive, but it works for me. There is an instance implementing the IApplicationContext interface. (The interface depends on the org.eclipse.equinox.app.) The instance is reachable by the injection mechanism. The method getArguments() returns a map. But it does not return a map of some command line parameters and their values. It returns some map, where it is under the key "application.args" stored an array. Exampli gratia: @PostConstruct public void createControls(Composite parent, HtmlEditorService editorService, IApplicationContext iac) { System.out.println(iac.getArguments().get("application.args").getClass().getCanonicalName()); ... } Then it prints out java.lang.String[]. However the array contains just my custom arguments instead all arguments.

Categories : Misc

Stored Procedure returns exception in .net but runs fine in sql server c# winforms
When you select the checkbox to pass null values, then it explicitly pass the NULL values alongwith the parameters. In your current code, you are not even passing the parameters that is why the exception. In current form your stored procedure is not ready to accept NULL values for startdate and enddate, you should modify your procedure as: @stardate datetime = NULL, @enddate datetime = NULL For passing NULL DateTime from C# use DateTime? or Nullable<DateTime>, which supports Null values.

Categories : C#

Blackberry webworks. App crashes second time it runs
I fixed my problem. I did not provide code, so I doubt you could have found it. But this was what caused my problem. I had a line of code like follows... $('#home').on('pageinit', function () {//work stuffs} Where it should have been... $('#home').bind('pageinit', function () {// work stuffs} I have no idea why exactly... But this solved my issues.

Categories : Misc

How to pass the enter key press to command line from a java application
I don't think it can be done: Either you launch a terminal/console/bash process, in which you can "type" commands, or you launch a specific executable that can't parse those commands and it won't work. Wouldn't it be easier to start 2 processes? Side note: you should not read the out and err streams one after the other, you should read them in parallel in separate threads, or, easier, use ProcessBuilder#redirectErrorStream so you only need to read from one stream (out).

Categories : Java

Hadoop Mapreduce code with parseDouble giving exception in one system, but runs fine in other?
You're getting a NullPointerException thrown from Double.parseDouble(String s) which happens if s is null. So, it sounds like you have some null input in your data on your "production" machine that doesn't reside on your "development" machine.

Categories : Java

Java jvm crashes without reason - runs with admin privileges
I would post this as a comment but I don't have enough rep. First of all can you tell us the version of windows you are running? 98/2000/XP/Vista/7/8? Take your application to another computer (with the same OS) and see if it crashes too. If yes try another OS from a different family (linux/mac). If the problem is isolated to a particular family of OS then the problem might be dependent to a particular method call in your program. If its just your computer then it becomes much harder to debug. If this problem happens to all OS families then suspect a JVM bug. If your using Windows Vista/7, try turning off UAC. Something about your user profile privileges might be blocking java from accessing a critical library (from the error dump User32.dll?). If this does solve you problems, once agai

Categories : Java

Running EXE application in GINA beofe login screen (Command line)
I see you tagged your question with "Gina", so I guess you know that Credential Providers do not exist on XP. Your answer depends on when exactly you want to run that program, especially with regards to the secure attention sequence (SAS, or when a user press CTRL-ALT-Delete) Before the SAS, use WlxDisplaySASNotice After the SAS, use WlxLoggedOutSAS Since you don't want to write a whole GINA yourself, you could use a custom Gina that wraps msgina.dll. Here is one I wrote, you can find the original I started from in the Platform SDK. Using that approch, you get a chance to execute code just before or just after certain events, like running your program after a successful logon, something like : int WINAPI WlxLoggedOutSAS(PVOID pWlxContext, DWORD dwSasType, PLUID pAuthenticationId, P

Categories : Windows

App working fine on emulator but crashes after downloading from store
When creating an application that is going to be used worldwide, you must keep in mind that different countries use different ways of formatting dates or formatting number. When you use a parse method (double.Parse, DateTime.Parse, ...) without specifying a culture, the user's culture will be used, which often leads to crashes. The workaround is simply to specify the culture you want to use. In the case of a date, you can event specify the precise date format you want to use. // Parse a number by forcing the culture to en-US double.Parse("13.25", CultureInfo.GetCulture("en-US")); // Parse a date by forcing the culture to en-US DateTime.Parse("12/31/2011", CultureInfo.GetCulture("en-US")); // Parse a date by specifying the format DateTime.ParseExact("12/31/2011", "MM/dd/yyyy", CultureI

Categories : Windows Phone 8

Adding modifier-based keyboard shortcuts to a Ruby command-line application
Install highline gem - should permit you to trap all kinds of key combinations (without requiring the user to press enter after the key). See this question for some more detail: How to get a single character without pressing enter? If you do use highline, at least in my testing, you may (or may not) be able to use Kernel.trap to grab key events like Ctrl-C so you should handle those manually. Highline will trap any key and let you detect ctrl-d vs d. It won't detect the difference between ctrl-d and ctrl-shift-d however, nor does it distinguish alt-d from d. Here's some basic code: require "highline/system_extensions" include HighLine::SystemExtensions print "Press any key:" k = get_character Kernel.abort(" Ctrl-C - exiting.. ") if k == 3 puts puts k.chr

Categories : Ruby

Open OSX application command line solution bypassing graphical admin password
If access for assistive devices has been enabled, you can use GUI scripting to interact with the password dialogs: tell application "System Events" to tell process "SecurityAgent" set value of text field 2 of scroll area 1 of group 1 of window 1 to "pa55word" click button 2 of group 2 of window 1 end tell osascript -e 'do shell script "ls ~root" with administrator privileges' & sleep 1 osascript -e 'tell application "System Events" to tell process "SecurityAgent" set value of text field 2 of scroll area 1 of group 1 of window 1 to "pa55word" click button 2 of group 2 of window 1 end tell' Normally for example sudo open -a Finder doesn't open Finder as root, but sudo /System/Library/CoreServices/Finder.app/Contents/MacOS/Finder does.

Categories : Osx

Deploying a Ruby Command Line Application that Depends on Non-Rubygems-Hosted Gems
bundle exec sets up your load path correctly so that the gems are visible when you require bundler/setup. One option would be to always run your binary with bundle exec bin/hippo. Something more suited to your purposes might be to run bundle install --standalone, which generates a bundle/bundler/setup.rb file within your project's directory. That file sets up load paths correctly for you, so you'd just need to do something like require_relative '../bundle/bundler/setup' from your binary instead of require 'bundler/setup'.

Categories : Ruby

Trying to run Libgdx app on Android, but it crashes. Desktop version works fine
I don't have seen you shaders but i think if you remove the f suffix from the float numbers(0.16f -> 0.16) the shaders should compile with no problem. There are many differences beetween different gpu's and especially between the ones in phones(like the adreno 200) and the ones in pc's ,one of them seems to bee the f suffix on the float numbers .Thats why it compiles with no problem on pc but not on android.

Categories : Android

Which event runs line by line in the DataGridView Windows Forms C #?
You got the DataBindingComplete or CellFormatting witch could do what you want edit : You could also use the Load event of the form to apply your formatting only once

Categories : C#



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.