w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Inconsistency in sql query output using OR after WHERE
When strfldvar = 'BROKEN_ARROW' AND x = g (or if strfldvar is not BROKEN_ARROW or BROKEN_BOX), the y = g part is not evaluated, which seems to be causing the query to run for longer than you expect - until it's eventually killed by you, your client or resource limits. I suspect that's the only join condition for whichever table y is from, so you end up with a cartesian product. When strfldvar = 'BROKEN_BOX' then both x = g and y = g will be evaluated, so you wouldn't get the same cartesian product, against either of the tables providing x and y. If you are essentially deciding which table to include in the query based on that flag then you'll need to redesign this; possibly with a union of two queries, one which joins to x and the other on y; or with separate queries and you decide which

Categories : SQL

AWS EMR machines not combining reduce output
I am running into the same issue - I am using EMR to create an "inverted index" using the streaming API: -input s3n://mybucket/html2 -output s3n://mybucket/results -mapper s3n://mybucket/mapper.py -reducer s3n://mybucket/reduce.py Where //mybucket/html2 has a few html files and mapper.py: def main(args): for line in sys.stdin: line = line.strip() words = line.split() for word in words: #do some preprocessing if word.startswith("http://"): #output the URL with a count of 1 print "%s,%s" % (word, 1) else: #cleanup HTML tags url = get_url() #irrelevant print "%s,%s" % (word, url) if __name__ == "__main__": main(sys.ar

Categories : Amazon

Capture output of a bash command, parse it and store into different bash variables
You can use awk and bash arrays: arr=( $(awk -F ':' '$1 == "inet addr"{sub(/ .*/, "", $2); print $2}' < <(ifconfig)) ) Then you can do: read IPETH0 IPLO <<< ${arr[@]}

Categories : Linux

mingw -- cl is not recognized as an internal or external command -- my mingw in new and environment is true
As I mentioned in the comment to your question, its looking for the Windows compiler, which you probably dont have installed. According to the SCons man page, you can fix this as follows: MinGW The MinGW bin directory must be in your PATH environment variable or the PATH variable under the ENV construction variable for SCons to detect and use the MinGW tools. When running under the native Windows Python interpreter, SCons will prefer the MinGW tools over the Cygwin tools, if they are both installed, regardless of the order of the bin directories in the PATH variable. If you have both MSVC and MinGW installed and you want to use MinGW instead of MSVC, then you must explictly tell SCons to use MinGW by passing tools=['mingw'] to the Environment() function, be

Categories : Python

SCP Progress bar like WGET in bash script
You can use pv Some examples here

Categories : Bash

Windows Workflow Progress Output
After some fiddling and rethinking I was able to achieve the type of output I desired. Essentially I kept using the logging that I was using during the states for ActivityStateQuery. What I added was an additional query to the tracking profile. I added an ActivityScheduledQuery. The ActivityScheduledRecord gives the activity scheduling the activity and the child activity. This allows me to create the child's log node under the parent's node. The id on the ActivityInfo object for the child node matches the id when the "Executing" state happens for the activity and I can then link up log messages and state messages during the ActivityStateQuery. This is the tracking profile for my tracking participant object: TrackingProfile = new TrackingProfile { Queries =

Categories : C#

Output Window Progress Display
Can you put an "[System.Windows.Forms.Application]::DoEvents()" between the PowerShell commands? Without it you aren't allowing the form event handler to process a repaint between each command. You would need this immediately after the Write-Host line. I see a good write-up here: Powershell Job Event Action With Form Not Executed

Categories : Visual Studio

Observable.Create doesn't work and Observable.ToEnumerable blocks indefinitely
This is incorrect: var observable = Observable.Create<int>(o => new Action(() => { o.OnNext(0); o.OnCompleted(); })); You meant to provide a function that calls OnNext upon subscription. However, you've inadvertently called the wrong overload of Observable.Create and provided it with a function which does nothing but create an action (which will be called upon disposal of the subscription). So (by mistake), you're trying to call OnNext only when the subscription is disposed. This is what you meant to do: var observable = Observable.Create<int>(o => { o.OnNext(0); o.OnCompleted(); return () => Console.WriteLine("Disposed!"); // this will be called when // subscription is disposed }); Or t

Categories : C#

Make observable arrays created via ko.mapping.fromJS not have observable elements
You can use the mapping plugin create option. From the ko docs (http://knockoutjs.com/documentation/plugins-mapping.html): // The data to be mapped var data = { name: 'Graham', children: [ { id : 1, name : 'Lisa' } ] }; // Your custom data model var myChildModel = function (data) { this.id = data.id; this.name = data.name; }; var mapping = { 'children': { create: function(options) { return new myChildModel(options.data); } } }; var viewModel = ko.mapping.fromJS(data, mapping); From this example the 'children' array will be mapped like an observable array, where the properties are not observables.

Categories : Javascript

Why is Observable.Finally not called when Observable.Generate finishes?
Look at the return type of the Finally method; should give you a hint. Just like the Concat method returns a new IObservable with the new sequence concatenated to it, but doesn't change the original, the Finally method returns a new IObservable that has that final action, but you're subscribing to the original IObservable. Put the following line in front of your Subscribe call and it'll work. o = o.Finally(() => "finallY".Dump()); I agree it's an odd API choice though; I'd think of Finally as being more akin to Subscribe than to Concat. You're subscribing to the finally "event"; it's odd that the API forces you to create a completely new IObservable and then subscribe to that just to get the Finally thing to happen. Plus it allows a potential error (made evident if we use the func

Categories : C#

How to do Knockout observable objects inside observable array
If you set up your users in a viewModel and map it with knockout mapping you should get the desired result. Something like: myObservableArray.push(new UserViewModel( {"name":"john","age":21,"address":"No 25"} )); var UserViewModel = function(data){ var self = this; ko.mapping.fromJS(data, {}, self); } This way each of the mapped properties will be an observable and when they change, this will be reflected in your markup.

Categories : Javascript

Knockout subscribe to observable in js object within an observable array
Your CoffeeScript syntax in wrong because subscribe is a function on the ko.observable where you need to pass in a callback function as the argument. So the correct syntax is: wol.work_item_id.subscribe (val) -> console.log val So no need for the = which by the way overrides the orginal subscribe with a new function.

Categories : Knockout Js

PHP+cURL disable command line progress output
From the manual refering to CURLOPT_NOPROGRESS: CURLOPT_NOPROGRESS TRUE to disable the progress meter for cURL transfers. Note: PHP automatically sets this option to TRUE, this should only be changed for debugging purposes. Looks like the progress has been explicitly turned on. Check you code for that option. In any case, if you want to explicitly disable it again, curl_setopt($curlHandle, CURLOPT_NOPROGRESS, true) should do the trick. Update: If you instead do something like exec("curl http://example.com") you should a) think about what you're doing and b) run curl -s to disable the progress. PHP's streams have support for http, so you can just use file_get_contents, copy et al.

Categories : PHP

Setting observable property of an observable in Knockout.js
try invoking the editedEvent observable first: timelineViewModel.editedEvent().timelineId(0); I got the same error initially in my test case, but that change did the trick for me!

Categories : Javascript

Azure VM pricing - Is it better to have 80 single core machines or 10 8-core machines?
Billing According to Windows Azure Virtual Machines Pricing Details, Virtual Machines are charged by the minute (of wall clock time). Prices are listed as hourly rates (60 minutes) and are billed based on total number of minutes when the VMs run for a partial hour. In July 2013, 1 Small VM (1 virtual core) costs $0.09/hr; 8 Small VMs (8 virtual cores) cost $0.72/hr; 1 Extra Large VM (8 virtual cores) cost $0.72/hr (same as 8 Small VMs). VM Sizes and Performance The VMs sizes differ not only in number of cores and RAM, but also on network I/O performance, ranging from 100 Mbps for Small to 800 Mbps for Extra Large. Extra Small VMs are rather limited in CPU and I/O power and are inadequate for workloads such as you described. For single-threaded, I/O bound applications such as describe

Categories : Azure

Sort output in bash
You can simply add sort to end of your loop to sort the outputs. #!/bin/bash for i in `find . ! -path "*/target/*" -type f -name pom.xml` do grep -q 'IC_Maven_JEE_Parent|IC_Maven_Parent' $i if [ "$?" -eq 0 ]; then echo $(grep -o 'IC_Maven_JEE_Parent|IC_Maven_Paren' $i) $(echo -e 'setns x=http://maven.apache.org/POM/4.0.0 cat /x:project/x:parent/x:version/text()' | xmllint --shell $i | grep -v /) $i fi done | sort

Categories : Linux

Bash, printing after output on new
Depends what you consider 'normal'. All programs are set of 0 and 1 arrange in special order. Apparently, 'G' and '1' in base64 are 'enter' and 'end of line' respectively. To confirm this just change the sequence to any other.

Categories : Bash

Bash non scrolling terminal output
Instead of printing whole lines (as with println or printing %n), write backspace characters () or bare carriage returns without linefeeds ( ) to move the cursor back in front of what you want to print over.

Categories : Java

redirect the output into a new column in bash
This should help you - #!/bin/bash echo job_id run_id for i in {1..10} do wget www.abc.com?id=$i > sample.txt job_id_var=$(grep -E "jobId" sample.txt) # return 5 in first iteration, 10 in second run_id=$(grep -E "runid" sample.txt) # return 1001 in first iteration, 1002 in second echo "$job_id_var" "$run_id" >> outputfile done Explanation: Using echo $YOUR_VAR >> filename, you can append out the variables to files as you want them. I haven't formated this well, may be you could do that. I also saw you used >> to append the sample.txt - I suggest you overwrite using >, if it can solve your problem.

Categories : Bash

Parse SNMP output in Bash
Pipe through sed as shown below: $ snmpwalk -v2c -c community 192.168.122.15 .1.3.6.1.4.1.14823.2.2.1.4.1.2.1.39 | sed -r 's/.*.([0-9]+.[0-9]+.[0-9]+.[0-9]+) = .*: (.*)/1=2/g' 197.39.5.77="Android"

Categories : Linux

Bash output to multiple variales
Answer: readarray -t interfaces < <(ip link | grep "<" | cut -d " " -f 2 | cut -d ":" -f 1 | grep -v lo) echo "${interfaces[0]}" # prints eth0 echo "${interfaces[1]}" # prints wlan0 And to loop over them use for: for curInterface in "${interfaces[@]}"; do echo "$curInterface" done But there are better ways to parse data: First of all, instead of grepping < character you can use -o flag. This will output all of the data on single lines. Then you simply need the second word without : character. This is very simple in pure bash: interfaces=() while read -r _ curInterface _; do interfaces+=("${curInterface%:}") done < <(ip -o link)

Categories : Bash

Suppress warning output in bash
Better give your exact code attempt and warnings in your original post, but if you try this one : { mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root mysql; } 2>/dev/null or mysql_tzinfo_to_sql 2>/dev/null /usr/share/zoneinfo | mysql -u root mysql 2>/dev/null that should work.

Categories : Mysql

Parse MegaCLI output using BASH
When you say "ONLY BASH", do you really mean it? bash by itself is pretty powerless; it really depends on having a collection of non-builtin commands available to do anything nontrivial. Also, do you really just want the selected lines, or do you want to reformat the info at all? If you just want the lines (and maybe a little header info) and have egrep available, this is simple: MegaCLI -whateveroptions | egrep '^(Adapter|Product Name|RAID Level Size State|Number Of Drives|Physical Disk|Raw Size|Link Speed|Media Type|Drive Temperature):` If you really need 100% pure bash, you can do it with read, case, and echo: MegaCLI -whateveroptions | while read line; do case "$line" in Adapter:* | Product Name:* | RAID Level Size State:* | Number Of Drives:

Categories : Bash

sed output blank in bash script
If you're going to use the flag -i, --in place, you don't have to redirect the output. The substitutions are performed in place, as expected. Yet, you can simplify your expression, doing: sed -i -e 's/abc-wxyz1/2222 ([0-9]+)/*/g' input.txt

Categories : Bash

I'd like to grep the output of ifconfig in bash
use this: ONLINE=$(ifconfig | grep -cs 'status: active') cause without "$" what bash will return is the result of the command being successful or not and if it is successful it is always zero.

Categories : Bash

How to hide command output in bash
You can redirect stdout to /dev/null. yum install nano > /dev/null Or you can redirect both stdout and stderr, yum install nano &> /dev/null. But if the program has a quiet option, that's even better.

Categories : Bash

Printing out wrong output in bash
You keep appending to the modified name. Use the original name instead. And that condition... origname="$name" while [ -f $name.contact ]; do name="$origname($count)" count=$(($count+1)) done

Categories : Bash

Bash : echo binary output
Perhaps you need to use the -n option? echo -n "$SIZE" >> quota Or maybe you need the binary representation it but this is only limited to 8 bits or 255. echo -ne "$(printf '\x%x' 200)" >> quota Also make sure that you really need to use >> and not > as >> appends data to existing files, not overwrite it.

Categories : Bash

How to avoid blackboxing function output in bash?
How are you executing the script, and what's calling main()? Bash scripts aren't like C programs and don't require a main() function. Bash will "remember" any functions it sees, but you actually need to call them directly from the script. Try this: # Start of script prompt() { read -p "This is an example prompt. [Y/n]" } prompt # End of script bash$ chmod +x script_name bash$ ./script_name

Categories : Bash

Change output path of program in bash
APPDATA=%CD%/certainfolderforportablestuff in bash should be APPDATA=$PWD/certainfolderforportablestuff And since you're just starting with bash I suggest that you place variables inside double quotes by default: APPDATA="$PWD/certainfolderforportablestuff"

Categories : Osx

Check for ftp authentication output for bash script
The message below is probably going to stderr instead of stdout so you will need to capture the stderr output first: while true do if ( script 2>&1 |grep -q 'Authentication failed' ) then echo "authentication failed, sleeping for a while before trying again" sleep 60 else #everything worked, break out of the while loop break fi done

Categories : Linux

Checking output of multiple variables in bash
the test command allows compound statements. If you just want to check that each of the strings is non-empty: if [ -z "$LSIBATTSTATE" -o -z "$LSIBATT" -o -z "$LSIWB" -o -z "$ADAPZMM" ]; then [error stuff] fi If you want something a little bit more extensible, you could run an array or sum of result codes: Initialize RESULTS=() RESULTSUM=0 Update after each command RESULT=$? RESULTS[${#RESULTS[*]}]=$RESULT RESULTSUM=$(($RESULTSUM + $RESULT)) Then after they are all done: if [ $RESULTSUM -eq 0 ]; then [error stuff which can use $RESULTS array to know which command failed] fi

Categories : Linux

tail not providing output in bash script
Try this: phonenumber=$(tail -f /var/log/asterisk/messages | awk 'match($12, /[^0-9]91([0-9]{10})@default/, a) {print a[1]; exit}') Your version doesn't work because tail -f and awk are in an infinite loop. Adding exit to the awk script terminates the loop when the first phone number is found. awk exits immediately and its output is put into the variable, and tail -f gets a SIGPIPE signal when it tries to write the next line to the pipe, which causes it to exit.

Categories : Linux

Pick a specific value in a program output (Bash)
Try grep in PCRE mode (-P), printing only the matched parts (-o), with a lookahead assertion: $ echo "Accuracy = 80% (24/30) (classification)" | grep -Po '[0-9]+(?=%)' 80 The regexp: [0-9] # match a digit + # one or more times (?=%) # assert that the digits are followed by a %

Categories : Linux

explain bash variable assignement output
Because echo $test > test2 writes the output to a file named test2. this set of commands is does what you would expect: test="zut"; echo $test; test2=$test; echo "echo test " $test2

Categories : Bash

Bash filtering output when receiving input
You'll need to not use while read, since read only processes "complete" lines, i.e. lines that end with LF. (Alternatively, read has an option -d delim which tells it to treat another delimiter as the end-of-line marker - in your case, this could be the question mark, or the : at the end of the prompt. However, I'll guess you can't use this in your particular case because you won't be able to predict when to use -d). Depending on what exactly your script is doing, you might be able to pipeline the entire tweaking, e.g. through sed, awk and the likes. For a more detailed answer, you'll need to post the innards of your current script.

Categories : Bash

Why does power of two >62 in bash output negative values or zero?
Calculations are being made on signed 64 bit integers. Therefor 2^62 is in positive range of 64 bit signed integer 2^63 is lowest negative 64 bit signed integer as it is over highest positive 2^63-1 2^64 and greater results in overflow and 0 is displayed Python offers your better handling of large numbers than bash. $ python -c 'print 2**256' 115792089237316195423570985008687907853269984665640564039457584007913129639936

Categories : Bash

Bash recursive capturing of commands output
Use the dollar parenthesis syntax for recursively capturing command output: base=$(basename $(readlink link)) The issue with the back-ticks is that when the interpreter encounters the second back-tick, the interpreter thinks the back-tick closes the first command whereas what you want is to open a new command.

Categories : Linux

How do I retrieve the header when I want to look at grep output of something in bash?
With awk: command | awk 'NR==1||/bla/' Thanks to @doubleDown for pointing out that {print} is unnecessary since it is the default action. With perl: command | perl -ne 'print if $.==1 or /bla/' (If you need perl irregular expressions, perl is probably available :) )

Categories : Bash

Bash - output of command seems to be an integer but "[" complains
If the output of the ssh command is truly just an integer preceded by optional tabs, then you shouldn't need the sed command; the shell will strip the leading and/or trailing whitespace as unnecessary before using it as an operand for the -lt operator. if [ $(ssh -tti id_dsa headless@remoteserver.com "ps -auxwww | grep -c pipeline") -lt 3 ]; then It is possible that result of the ssh is not the same when you run it manually as when it runs in the shell. You might try saving it in a variable so you can output it before testing it in your script: result=$( ssh -tti id_dsa headless@remoteserver.com "ps -auxwww | grep -c pipeline" ) if [ $result -lt 3 ];

Categories : Bash



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