I have a file with two columns,
sdfsd 1.3
sdfds 3
sdfsdf 2.1
dsfsdf -1
if x is 2
I want to print sdfsdf 2.1
How to express it in awk (bash or sed is fine too)
The age old question. <object> vs <embed>. From what I gather, <object> is the XHTML-compliant way of doing things, while <embed> is for legacy support. I'm currently building a Flash application that will contain a pre-made embedding code for users to copy and paste, and I'm wondering if it's feasible to simply dump the <embed> tag altogether.
Which browsers would be unable to load my application if I gave my users an <object>-only embed code?
Thanks :)
Is there a way to access the Java Plug-in Control Panel programatically? Or at least find the places in the Windows File System where the information backing that control panel is stored?
I have to get certain count from files. The grep statement i am using is like this :
counter_pstn=0
completed_count_pstn=0
rec=0
for rec in `(grep "merged" update_completed*.log | awk '{print $1}' | sed 's/ //g' | cut -d':' -f2)`
do
if [ $counter_pstn -eq 0 ]
then
completed_count_pstn=$rec
else
completed_count_pstn=$(($completed_count_pstn+$rec))
fi
counter_pstn=$(($counter_pstn+1))
done
echo "Completed Orders PSTN Primary " $completed_count_pstn
But the log file contains data in this format :
2500 rows merged.
2500 rows merged.
2500 rows merged.
2500 rows merged.2500 rows merged.
2500 rows merged.
2500 rows merged.
As a result , it is missing out the count of one merge(eg on line 4 of output).How do i modify the grep or use another function to get the count. NOTE that the 2500 number maybe for different logs. So we have to use "rows merged" pattern to get the count. i have tried -o ,-w grep options,but it is not working.
Expected output from above data:
17500
Actual output showing :
15000
Hi all,
I have a C++ library, which is used in both Linux and Windows.
I want to enable the user to control the debug level (0 - no debug, 1 - only critical errors ... 5 - informative debug information).
The debug log is printed to a text file.
In Windows, I can do it using a registry value (DWORD DebugLevel).
What can be a good replacement which works also for Linux?
(Without 3rd party tools, for example Linux "registry").
Thanks in advance!
I need to dynamically load a CSS stylesheet into a page that's on a different domain. How can I get the complete URL of the JS file to use in the href attribute of the stylesheet?
For instance, here is the structure:
http://bla.com/js/script.js
http://bla.com/css/style.css
I want to dynamically load the stylesheet into a page http://boo.net/index.html. The problem is, I don't know the bla.com bit in advance, just the fact that the stylesheet is in ../css/ relative to the JS file.
The script is, of course, included on index.html. jQuery's fine too.
Hello,
I believe this question has been asked a lot of times, and I have managed to overcome this problem before whenever it occurred. Just now, I feel stuck with it and can't find a proper solution to make it work in all browsers: it does work properly only in Firefox, while in IE and Safari its elements are somehow apart from each other. You can see the result here:
http://img813.imageshack.us/img813/8393/firefox.png
http://img812.imageshack.us/img812/8041/10990669.png
This is the code I use:
http://pastebin.com/n6KEjazp
Thank you very much in advance!
I'm trying to write a small script to change the current directory to my project directory:
#!/bin/bash
cd /home/askgelal/projects/java
I saved this file as proj, changed the chmod, copied it to /usr/bin. When I call it by:
proj, it does nothing. What am I doing wrong?
Hello all,
I have the following command which will take ages to run (couple of hours). I would like to make it a background process and for it to send me an email when its done.
For the cherry on the top, any errors it encountered should write to a text file when an error has occurred?
find . -type f -name "*.rm" -exec ./rm2mp3.sh \{} \; -exec rm \{} \;
How can I do this with my above command?
Hi i am trying to read json from a remote host by using this piece of code.
<!DOCTYPE html>
<html>
<head>
<script src="jquery.js"></script>
<script>
$(document).ready(function(){
$("button").click(function(){
$.getJSON("http://50.116.19.49/rest/user.json",function(result){
$.each(result, function(i, field){
$("div").append(field + " ");
});
});
});
});
</script>
</head>
<body>
<button>Get JSON data</button>
<div></div>
</body>
</html>
The problem is when i type the url in browser i get json from it. But failed to get json by using the above jquery method.
Can someone help in this regard. Thanks
I have this terrible problem with IE 7/8/9.
I wrote an app using Dojo toolkit 1.8.0 and Play! framework. It works fine in all browser except for IE. Its 'developers tools' show no error, so does firebug. The problematic code section is here:
<div data-dojo-type="dijit.layout.BorderContainer" data-dojo-props="design: 'headline'">
<div data-dojo-type="dijit.layout.ContentPane" id="head" region="top">
</div>
<div data-dojo-type="dijit.layout.BorderContainer" data-dojo-props="region: 'center'">
<div data-dojo-type="dijit.layout.ContentPane" id="menu" region="left">
</div>
<div data-dojo-type="dijit.layout.BorderContainer" data-dojo-props="region: 'center'">
<div data-dojo-type="dijit.layout.ContentPane" id="content_1" region="top">
</div>
<div data-dojo-type="dijit.layout.ContentPane" id="content_2" region="bottom">
</div>
</div>
</div>
<div data-dojo-type="dijit.layout.ContentPane" id="foot" region="bottom">
</div>
</div>
The result, in all browsers except for IE is like that:
But in IE it is shown like that:
Can anyone explain why there are such differences? At first I thought that in IE content is hidden, so I set overflow: auto, but no scrollbar appeared after page load.
Could someone explain how to use the Timer.schedule - that is used for scheduling tasks - in Python?
Note that Python's time.sleep will not work in Android.
Hi Everyone!
I get files in different formats coming from different systems that I need to import into our database. Part of the import process it to check the line length to make sure the format is correct.
We seem to be having issues with files coming from UNIX systems where one character is added. I suspect this is due to the return carriage being encoded differently on UNIX and windows platform.
Is there a way to detect on which file system a file was created, other than checking the last character on the line? Or maybe a way of reading the files as text and not binary which I suspect is the issue?
Thanks Guys !
Hi,
I want to create a script that checks an URL and perform an action (download + unzip) when the "Last-Modified" header of the remote file changed. I thought about fetching the header with curl but then I have to store it somewhere for each file and perform a date comparison.
Does anyone have a different idea using (mostly) standard unix tools?
thanks
Hello fellow front-end web h4X0|2s,
I was wondering if anyone had any resources, proof, or personal experience in using the age-old http/https JavaScript hack:
<script src="//someserver.com/js/script.js"></script>
Has anyone encountered issues in any of these browsers (IE 5.5+, FF2+, Chrome, Opera 9+, Safari 3+)? Has anybody had success stories?
Thank you for your help.
Screen is amazing, of course, but I don't want to have to think about it. I often ssh to a machine, start doing a bunch of stuff, and then think "gosh, I wish I had thought to start a screen session before doing all that so I could reconnect to this from home later".
I'd like to have screen automatically started whenever I log in to a machine.
And when I get disconnected, I want to be able to immediately and simply reconnect without fussing with "screen -ls" and "screen -dr".
I have a script that implements one solution to this problem which I'll post as an answer. I'm interested to see other approaches.
Hello,
I have this shell script
#!/bin/sh
#############################################################
# Example startup script for the SecureTrading Xpay4 client #
# Install Xpay4 into /usr/local/xpay4 #
# To run this script automatically at startup, place the #
# following line at the end of the bootup script. #
# eg. for RedHat linux: /etc/rc.d/rc.local #
# #
# /usr/local/xpay4/xpay4.sh #
#############################################################
# Configuration options
# Path to java executable
JAVAPATH=/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home
########## Do not alter anything below this line ##########
echo "Starting Xpay4. Please ensure the Xpay4 client is not already running"
$JAVAPATH/java -jar /usr/local/xpay4/Xpay4.jar /usr/local/xpay4/xpay4.ini &
And I am trying to run it using,
system("/x/sh/shell.sh");
I am doing this when a user navigates to a certain page on my site, however I am getting just a white blank screen is there a way to error check with system(), I am currently using
error_reporting(E_ALL | E_STRCIT)
and that is applied site wide
Is there a way to execute commands using directory traversal attacks?
For instance, I access a server's etc/passwd file like this
http://server.com/..%01/..%01/..%01//etc/passwd
Is there a way to run a command instead? Like...
http://server.com/..%01/..%01/..%01//ls
..... and get an output?
EDIT: To be clear here, I've found the vuln in our company's server. I'm looking to raise the risk level (or bonus points for me) by proving that it may give an attacker complete access to the system
I tried this,
#!/bin/ksh
for i in {1..10}
do
echo "Welcome $i times"
done
in Ksh of an AIX box.
I am getting the output as,
Welcome {1..10} times
What's wrong here?
Thanks.
Considering the criteria listed below, which of Python, Groovy or Ruby would you use?
Criteria (Importance out of 10, 10 being most important)
Richness of API/libraries available (eg. maths, plotting, networking) (9)
Ability to embed in desktop (java/c++) applications (8)
Ease of deployment (8)
Ability to interface with DLLs/Shared Libraries (7)
Ability to generate GUIs (7)
Community/User support (6)
Portability (6)
Database manipulation (3)
Language/Semantics (2)
My problematic code:
testMYSQL=`mysql -u $mysqlUser -p$mysqlPass -h $mysqlHost --skip-column-names --batch -D $mysqlDB -e "SELECT $select FROM $mysqlTable WHERE nameTXT='test';"`
$testMYSQL now contains:
test
test
test
Then I do:
TEST=$(echo $testMYSQL | wc -l)
echo "$TEST"
I would of thought that would work, but it doesn't, it returns 1
But if I put this into $testMYSQL: "test\ntest\ntest" it will say 3…
Whats going on here? does MYSQL not use new lines?
PS, I know I can use a for loop to loop though the lines then count up the lines that way, but I was hoping for a simpler solution like wc