Search Results

Search found 18596 results on 744 pages for 'c how to detect all ip addresses from a lan'.

Page 98/744 | < Previous Page | 94 95 96 97 98 99 100 101 102 103 104 105  | Next Page >

  • Why is my SSH session timing out in less than a minute?

    - by John Smith
    Within a minute of connecting to my remote Linux server through SSH, my session times out and I cannot contact the server until a few seconds have passed. Meanwhile, I'm connected to other servers without interruption. This is only happening when I establish connection from an hotel wireless AP. When I connect from my phone's Internet, the problem does not occur. Does anyone know what might be causing these unusual timeouts?

    Read the article

  • Upon USB insert, record unique identifer sting, format drive to FAT32 and copy a file. Bash or Pytho

    - by samsixty
    Hello, This is what I want to do, insert USB flash drive. mount it. record uniquie identifer string to a file. format the drive to FAT32. copy a text file to the drive. unmount it. remove the drive. 30 times The situation is this, I have bought 30 usb drives. I need to format each one to ensure they are clean, I need the unique string from each device. I need to put the same txt file on each one. I am not great at writing scripts but can read and follow bash and python. Any pointers would be appreciated.

    Read the article

  • Bind9 as a caching resolver fails with mismatch ID on localhost but not external IP

    - by argibbs
    I'm running Ubuntu 12.04 LTS on a machine on my private network. I have bind9 installed (v9.8.1-P1) via aptitude, so it appears to have put all the bits in the right places and the service starts automatically. I plan on adding some zones later, but first I'm just trying to get it working as a caching resolver. I installed bind, configured it, and starting using it. Initially I thought it was working ok, but then I found some sites weren't being resolved. I've pinned it down to being linked to the size of the result and bind failing-over to TCP mode. So: I'm trying to find out why bind is failing when I query for domain info and the result is 512 bytes (causing a truncation and retry on TCP). Specifically it fails with ID mismatches if I point dig at localhost, but works when I query the machine's own IP (192.168.0.2). This appears to be backwards to the problem that most people have when using bind (fails on external ip, works on localhost). If I do dig @localhost google.com (which has a response of <512 bytes) then it works; I get no warnings, and plenty of output. $ dig @localhost google.com ; <<>> DiG 9.8.1-P1 <<>> @localhost google.com [snip lots of output] ;; Query time: 39 msec ;; SERVER: 127.0.0.1#53(127.0.0.1) ;; WHEN: Thu Oct 17 23:08:34 2013 ;; MSG SIZE rcvd: 495 If I do dig @localhost play.google.com (which has a larger response) then I get back something like: $ dig @localhost play.google.com ;; Truncated, retrying in TCP mode. ;; ERROR: ID mismatch: expected ID 3696, got 27130 This seems to be standard, documented behaviour - when the UDP response is large (here 'large' == 512 bytes) it falls back to TCP. The ID mismatch is not expected though. If I do dig @192.168.0.2 play.google.com then I still get the warning about using TCP mode, but it otherwise works $ dig @192.168.0.2 play.google.com ;; Truncated, retrying in TCP mode. ; <<>> DiG 9.8.1-P1 <<>> @192.168.0.2 play.google.com [snip most of the output] ;; Query time: 5 msec ;; SERVER: 192.168.0.2#53(192.168.0.2) ;; WHEN: Thu Oct 17 23:05:55 2013 ;; MSG SIZE rcvd: 521 At the moment I've not set up any zones in my local instance, so it's just acting as a caching resolver. My options config is pretty much unchanged from standard, I've got the following set: options { directory "/var/cache/bind"; allow-query { 192.168/16; 127.0.0.1; }; forwarders { 8.8.8.8; 8.8.4.4; }; dnssec-validation auto; edns-udp-size 4096 ; allow-transfer { any; }; auth-nxdomain no; # conform to RFC1035 listen-on-v6 { any; }; }; And my /etc/resolv.conf is just nameserver 127.0.0.1 search .local The problem definitely seems linked to the failover to TCP mode: if I do dig +bufsize=4096 @localhost play.google.com then it works; no warning about failover to TCP, no ID mismatch, and a standard looking result. To be honest, if there was a way to force bind to use a much larger UDP buffer, that'd probably be good enough for me, but all I've been able to find mention of is max-udp-size 4096 and that doesn't change the behaviour in any way. I've also tried setting edns-udp-size 512 in case the problem is some weird EDNS issue with my router (which seems unlikely since the +bufsize=4096 flag works fine). I've also tried dig +trace @localhost play.google.com; this works. No truncation/TCP warning, and a full result. I've also tried changing the servers used in the forwarder (e.g. to OpenDNS), but that makes no difference. There's one last data point: if I repetitively do dig @localhost play.google.com I don't always get an ID mismatch, but sometimes a REFUSED error. I'm much more likely to get a REFUSED error if I dig the non-localhost IP (192.168.0.2) first: $ dig @localhost play.google.com ;; Truncated, retrying in TCP mode. ; <<>> DiG 9.8.1-P1 <<>> @localhost play.google.com ; (1 server found) ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: REFUSED, id: 35104 ;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 0 ;; QUESTION SECTION: ;play.google.com. IN A ;; Query time: 4 msec ;; SERVER: 127.0.0.1#53(127.0.0.1) ;; WHEN: Thu Oct 17 23:20:13 2013 ;; MSG SIZE rcvd: 33 Any insights or things to try would be much appreciated.

    Read the article

  • Managing two domains in one virtual server [on hold]

    - by Buddhika Ariyaratne
    I have a virtual server with Windows Server 2012 on which I need to run two applications for two separate customers. Both applications run on GlassFish in port 8080. The applications run on http://localhost:8080/roseth and http://localhost:8080/ruhunu My virtual server provider has given three IP addresses. How can a I assign one address for each application. For example, if a user type www.ruhunu.org, an arbitrary URL , I want to direct to http://localhost:8080/ruhunu and www.roseth.org to http://localhost:8080/roseth.

    Read the article

  • How to calculate CIDR notation from entries in a routing table

    - by febreezey
    I have some entries in a routing table that were created using longest prefix matching, and I have to use those entries to determine the a.b.c.d/x notation (CIDR). This is an example entry: 11001000 00010111 00010. That was calculated from the range 11001000 00010111 00010000 00000000 through 11001000 00010111 00010111 11111111. I know the range is from IP addresses 200.23.16.0 to 200.23.23.255, but getting the /x for the subnet # doesn't make sense to me. Anyone know how to properly go about calculating it?

    Read the article

  • Bridging LXC containers to host eth0 so they can have a public IP

    - by Vianney Stroebel
    UPDATE: I found the solution there: http://www.linuxfoundation.org/collaborate/workgroups/networking/bridge#No_traffic_gets_trough_.28except_ARP_and_STP.29 # cd /proc/sys/net/bridge # ls bridge-nf-call-arptables bridge-nf-call-iptables bridge-nf-call-ip6tables bridge-nf-filter-vlan-tagged # for f in bridge-nf-*; do echo 0 $f; done But I'd like to have expert opinions on this: is it safe to disable all bridge-nf-*? What are they here for? END OF UPDATE I need to bridge LXC containers to the physical interface (eth0) of my host, reading numerous tutorials, documents and blog posts on the subject. I need the containers to have their own public IP (which I've previously done KVM/libvirt). After two days of searching and trying, I still can't make it work with LXC containers. The host runs a freshly installed Ubuntu Server Quantal (12.10) with only libvirt (which I'm not using here) and lxc installed. I created the containers with : lxc-create -t ubuntu -n mycontainer So they also run Ubuntu 12.10. Content of /var/lib/lxc/mycontainer/config is: lxc.utsname = mycontainer lxc.mount = /var/lib/lxc/test/fstab lxc.rootfs = /var/lib/lxc/test/rootfs lxc.network.type = veth lxc.network.flags = up lxc.network.link = br0 lxc.network.name = eth0 lxc.network.veth.pair = vethmycontainer lxc.network.ipv4 = 179.43.46.233 lxc.network.hwaddr= 02:00:00:86:5b:11 lxc.devttydir = lxc lxc.tty = 4 lxc.pts = 1024 lxc.arch = amd64 lxc.cap.drop = sys_module mac_admin mac_override lxc.pivotdir = lxc_putold # uncomment the next line to run the container unconfined: #lxc.aa_profile = unconfined lxc.cgroup.devices.deny = a # Allow any mknod (but not using the node) lxc.cgroup.devices.allow = c *:* m lxc.cgroup.devices.allow = b *:* m # /dev/null and zero lxc.cgroup.devices.allow = c 1:3 rwm lxc.cgroup.devices.allow = c 1:5 rwm # consoles lxc.cgroup.devices.allow = c 5:1 rwm lxc.cgroup.devices.allow = c 5:0 rwm #lxc.cgroup.devices.allow = c 4:0 rwm #lxc.cgroup.devices.allow = c 4:1 rwm # /dev/{,u}random lxc.cgroup.devices.allow = c 1:9 rwm lxc.cgroup.devices.allow = c 1:8 rwm lxc.cgroup.devices.allow = c 136:* rwm lxc.cgroup.devices.allow = c 5:2 rwm # rtc lxc.cgroup.devices.allow = c 254:0 rwm #fuse lxc.cgroup.devices.allow = c 10:229 rwm #tun lxc.cgroup.devices.allow = c 10:200 rwm #full lxc.cgroup.devices.allow = c 1:7 rwm #hpet lxc.cgroup.devices.allow = c 10:228 rwm #kvm lxc.cgroup.devices.allow = c 10:232 rwm Then I changed my host /etc/network/interfaces to: auto lo iface lo inet loopback auto br0 iface br0 inet static bridge_ports eth0 bridge_fd 0 address 92.281.86.226 netmask 255.255.255.0 network 92.281.86.0 broadcast 92.281.86.255 gateway 92.281.86.254 dns-nameservers 213.186.33.99 dns-search ovh.net When I try command line configuration ("brctl addif", "ifconfig eth0", etc.) my remote host becomes inaccessible and I have to hard reboot it. I changed the content of /var/lib/lxc/mycontainer/rootfs/etc/network/interfaces to: auto lo iface lo inet loopback auto eth0 iface eth0 inet static address 179.43.46.233 netmask 255.255.255.255 broadcast 178.33.40.233 gateway 92.281.86.254 It takes several minutes for mycontainer to start (lxc-start -n mycontainer). I tried replacing gateway 92.281.86.254 by : post-up route add 92.281.86.254 dev eth0 post-up route add default gw 92.281.86.254 post-down route del 92.281.86.254 dev eth0 post-down route del default gw 92.281.86.254 My container then starts instantly. But whatever configuration I set in /var/lib/lxc/mycontainer/rootfs/etc/network/interfaces, I cannot ping from mycontainer to any IP (including the host's) : ubuntu@mycontainer:~$ ping 92.281.86.226 PING 92.281.86.226 (92.281.86.226) 56(84) bytes of data. ^C --- 92.281.86.226 ping statistics --- 6 packets transmitted, 0 received, 100% packet loss, time 5031ms And my host cannot ping the container: root@host:~# ping 179.43.46.233 PING 179.43.46.233 (179.43.46.233) 56(84) bytes of data. ^C --- 179.43.46.233 ping statistics --- 5 packets transmitted, 0 received, 100% packet loss, time 4000ms My container's ifconfig: ubuntu@mycontainer:~$ ifconfig eth0 Link encap:Ethernet HWaddr 02:00:00:86:5b:11 inet addr:179.43.46.233 Bcast:255.255.255.255 Mask:0.0.0.0 inet6 addr: fe80::ff:fe79:5a31/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:64 errors:0 dropped:6 overruns:0 frame:0 TX packets:54 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:4070 (4.0 KB) TX bytes:4168 (4.1 KB) lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:32 errors:0 dropped:0 overruns:0 frame:0 TX packets:32 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:2496 (2.4 KB) TX bytes:2496 (2.4 KB) My host's ifconfig: root@host:~# ifconfig br0 Link encap:Ethernet HWaddr 4c:72:b9:43:65:2b inet addr:92.281.86.226 Bcast:91.121.67.255 Mask:255.255.255.0 inet6 addr: fe80::4e72:b9ff:fe43:652b/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:1453 errors:0 dropped:18 overruns:0 frame:0 TX packets:1630 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:145125 (145.1 KB) TX bytes:299943 (299.9 KB) eth0 Link encap:Ethernet HWaddr 4c:72:b9:43:65:2b UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:3178 errors:0 dropped:0 overruns:0 frame:0 TX packets:1637 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:298263 (298.2 KB) TX bytes:309167 (309.1 KB) Interrupt:20 Memory:fe500000-fe520000 lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:6 errors:0 dropped:0 overruns:0 frame:0 TX packets:6 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:300 (300.0 B) TX bytes:300 (300.0 B) vethtest Link encap:Ethernet HWaddr fe:0d:7f:3e:70:88 inet6 addr: fe80::fc0d:7fff:fe3e:7088/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:54 errors:0 dropped:0 overruns:0 frame:0 TX packets:67 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:4168 (4.1 KB) TX bytes:4250 (4.2 KB) virbr0 Link encap:Ethernet HWaddr de:49:c5:66:cf:84 inet addr:192.168.122.1 Bcast:192.168.122.255 Mask:255.255.255.0 UP BROADCAST MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B) I have disabled lxcbr0 (USE_LXC_BRIDGE="false" in /etc/default/lxc). root@host:~# brctl show bridge name bridge id STP enabled interfaces br0 8000.4c72b943652b no eth0 vethtest I have configured the IP 179.43.46.233 to point to 02:00:00:86:5b:11 in my hosting provider (OVH) config panel. (The IPs in this post are not the real ones.) Thanks for reading this long question! :-) Vianney

    Read the article

  • UBUNTU's Network Connection Manger can't detect Huawei ETS2051 Modem device!

    - by Doctoa
    I have a modem device called Huawei ETS2051 and the Network Connection Manger can't detect it, but when I use Gnome-PPP it work fine but the problem is when I use Gnome-PPP; apps like Ubuntu software Center Can't reconice that's Iam connecting to the Internet so the app is just act like it's offline while other apps like web browsers and IM's work good under Gnome-PPP. any way what I want is to have a Full Ubuntu experince by making The Network Connection Manger detect my ETS2051. I have another 3G USB modem and The Network Connection Manger detect it and it's work just fine but the internet price for this one is high and I can't effort it so am count on that ETS2051 modem as you can see for it's low price and stable internet speed that satesfy my needs. More information: Gnome-PPP is a GUI for wvdial. the ETS2051 modem use a serial USB port. I have a Windows driver CD for the device. I have also find This qustion about the software Center acting like it's offline around wvdial and there's this launchpad bug. and am really insest to use Ubuntu Software Center so please no other software manger apps recomendation... I've also this Genius ColorPage HR6X Slim scanner that's Ubuntu can't detect it, so if you interset you can check and answer the qustion from here...

    Read the article

  • Detect the language & django locale-url

    - by mamcx
    I want to deploy a website in english & spanish and detect the user browser languaje & redirect to the correct locale site. My site is www.elmalabarista.com I install django-localeurl, but I discover that the languaje is not correctly detected. This are my middlewares: MIDDLEWARE_CLASSES = ( 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.locale.LocaleMiddleware', 'multilingual.middleware.DefaultLanguageMiddleware', 'middleware.feedburner.FeedburnerMiddleware', 'lib.threadlocals.ThreadLocalsMiddleware', 'middleware.url.UrlMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'maintenancemode.middleware.MaintenanceModeMiddleware', 'middleware.redirect.RedirectMiddleware', 'openidconsumer.middleware.OpenIDMiddleware', 'django.middleware.doc.XViewMiddleware', 'middleware.ajax_errors.AjaxMiddleware', 'pingback.middleware.PingbackMiddleware', 'localeurl.middleware.LocaleURLMiddleware', 'multilingual.flatpages.middleware.FlatpageFallbackMiddleware', 'django.middleware.common.CommonMiddleware', ) But ALWAYS the site get to US despite the fact my OS & Browser setup is spanish. LANGUAGES = ( ('en', ugettext('English')), ('es', ugettext('Spanish')), ) DEFAULT_LANGUAGE = 1 Then, I hack the middleware of locale-url and do this: def process_request(self, request): locale, path = self.split_locale_from_request(request) if request.META.has_key('HTTP_ACCEPT_LANGUAGE'): locale = utils.supported_language(request.META['HTTP_ACCEPT_LANGUAGE'].split(',')[0]) locale_path = utils.locale_path(path, locale) if locale_path != request.path_info: if request.META.get("QUERY_STRING", ""): locale_path = "%s?%s" % (locale_path, request.META['QUERY_STRING']) return HttpResponseRedirect(locale_path) request.path_info = path if not locale: locale = settings.LANGUAGE_CODE translation.activate(locale) request.LANGUAGE_CODE = translation.get_language() However, this detect fine the language but redirect the "en" urls to "es". So is impossible navigate in english. UPDATE: This is the final code (after the input from Carl Meyer) with a fix for the case of "/": def process_request(self, request): locale, path = self.split_locale_from_request(request) if (not locale) or (locale==''): if request.META.has_key('HTTP_ACCEPT_LANGUAGE'): locale = utils.supported_language(request.META['HTTP_ACCEPT_LANGUAGE'].split(',')[0]) else: locale = settings.LANGUAGE_CODE locale_path = utils.locale_path(path, locale) if locale_path != request.path_info: if request.META.get("QUERY_STRING", ""): locale_path = "%s?%s" % (locale_path, request.META['QUERY_STRING']) return HttpResponseRedirect(locale_path) request.path_info = path translation.activate(locale) request.LANGUAGE_CODE = translation.get_language()

    Read the article

  • Detect a white square in a black and white image

    - by gcc
    I saw that question i one web site (cite name like that programm.) then i tried to solve but icannot (not my and myfriend homework ) how can i approach to that one (in program.net no solution there is ) Read black & white image data from standard input, and detect a white square in the image. Output the coordinates of the upper left corner of the square, and the width of the square. In the preliminary work, you can print the output and terminate your program after you detect your first square. If you can't find any square on the image, you will print the string: "NO DETECTION". Input (which represents a 2 by 2 square in the center of a 5 by 4 image): 2 2 5 4 0 0 0 0 0 0 0 255 255 0 0 0 255 255 0 0 0 0 0 0 Output: 3 2 2 Input (more comprehensible format of the image, with the same output): 2 6 4 000 000 000 000 000 000 000 000 255 255 255 000 000 000 000 255 255 000 000 000 000 000 000 000 Output: no detection Input can be: 000 255 255 000 000 000 000 255 255 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 255 255 255 000 000 000 255 255 255 000 000 000 255 255 255 000 000 000 000 000 000 000 If there are two squares detected, we should use the biggest one

    Read the article

  • javascript: detect if XP or Classic windows theme is enabled

    - by mkoryak
    Is there any way to detect which windows XP theme is in use? I suspect that there is no specific api call you can make, but you may be able to figure it out by checking something on some DOM element, ie feature detection. Another question: does the classic theme even exist on windows vista or windows 7? edit - this is my solution: function isXpTheme() { var rgb; var map = { "rgb(212,208,200)" : false, "rgb(236,233,216)" : true }; var $elem = $("<button>"); $elem.css("backgroundColor", "ButtonFace"); $("body").append($elem); var elem = $elem.get(0); if (document.defaultView && document.defaultView.getComputedStyle) { s = document.defaultView.getComputedStyle(elem, ""); rgb = s && s.getPropertyValue("background-color"); } else if (elem.currentStyle) { rgb = (function (el) { // get a rgb based color on IE var oRG =document.body.createTextRange(); oRG.moveToElementText(el); var iClr=oRG.queryCommandValue("BackColor"); return "rgb("+(iClr & 0xFF)+","+((iClr & 0xFF00)>>8)+","+ ((iClr & 0xFF0000)>>16)+")"; })(elem); } else if (elem.style["backgroundColor"]) { rgb = elem.style["backgroundColor"]; } else { rgb = null; } $elem.remove(); rgb = rgb.replace(/[ ]+/g,"") if(rgb){; return map[rgb]; } } Next step is to figure out what this function returns on non-xp machines and/or figure out how to detect windows boxes. I have tested this in windows XP only, so vista and windows 7 might give different color values, it should be easy to add though. Here is a demo page of this in action: http://programmingdrunk.com/current-projects/isXpTheme/

    Read the article

  • Algorithm detect repeating/similiar strings in a corpus of data -- say email subjects, in Python

    - by RizwanK
    I'm downloading a long list of my email subject lines , with the intent of finding email lists that I was a member of years ago, and would want to purge them from my Gmail account (which is getting pretty slow.) I'm specifically thinking of newsletters that often come from the same address, and repeat the product/service/group's name in the subject. I'm aware that I could search/sort by the common occurrence of items from a particular email address (and I intend to), but I'd like to correlate that data with repeating subject lines.... Now, many subject lines would fail a string match, but "Google Friends : Our latest news" "Google Friends : What we're doing today" are more similar to each other than a random subject line, as is: "Virgin Airlines has a great sale today" "Take a flight with Virgin Airlines" So -- how can I start to automagically extract trends/examples of strings that may be more similar. Approaches I've considered and discarded ('because there must be some better way'): Extracting all the possible substrings and ordering them by how often they show up, and manually selecting relevant ones Stripping off the first word or two and then count the occurrence of each sub string Comparing Levenshtein distance between entries Some sort of string similarity index ... Most of these were rejected for massive inefficiency or likelyhood of a vast amount of manual intervention required. I guess I need some sort of fuzzy string matching..? In the end, I can think of kludgy ways of doing this, but I'm looking for something more generic so I've added to my set of tools rather than special casing for this data set. After this, I'd be matching the occurring of particular subject strings with 'From' addresses - I'm not sure if there's a good way of building a data structure that represents how likely/not two messages are part of the 'same email list' or by filtering all my email subjects/from addresses into pools of likely 'related' emails and not -- but that's a problem to solve after this one. Any guidance would be appreciated.

    Read the article

  • How to detect changing directory size in Perl

    - by materiamage
    Hello, I am trying to find a way of monitoring directories in Perl, in particular the size of a directory, and upon detecting a change in directory size, perform a particular action. The issue I have is with large files that require a noticeable amount of time to copy into this directory, i.e. 100MB. What happens (in Windows, not Unix) is the system reserves enough disk space for the entire file, even though the file is still copying in progress. This causes problems for me, because my script will try to perform an action on this file that has not finished copying over. I can easily detect directory size changes in Unix via 'du', but 'du' in Windows does not behave the same way. Are there any accurate methods of detecting directory size changes in Perl? Edit: Some points to clarify: - My Perl script is only monitoring a particular directory, and upon detecting a new file or a new directory, perform an action on this new file or directory. It is not copying any files; users on the network will be copying files into the directory I am monitoring. - The problem occurs when a new file or directory appears (copied, not moved) that is significantly large ( 100MB, but usually a couple GB) and my program fires before this copy completes - In Unix I can easily 'du' to see that the file/directory in question is growing in size, and take the appropriate action - In Windows the size is static, so I cannot detect this change - opendir/readdir/closedir is not feasible, as some of the directories that appear may contain thousands of files, and I want to avoid the overhead of Ideally I would like my program to be triggered on change, but I am not sure how to do this. As of right now it busy waits until it detects a change. The change in file/directory size is not in my control.

    Read the article

  • Limit TCP requests per IP

    - by asmo
    Hello! I'm wondering how to limit the TCP requests per client (per specific IP) in Java. For example, I would like to allow a maximum of X requests per Y seconds for each client IP. I thought of using static Timer/TimerTask in combination with a HashSet of temporary restricted IPs. private static final Set<InetAddress> restrictedIPs = Collections.synchronizedSet(new HashSet<InetAddress>()); private static final Timer restrictTimer = new Timer(); So when a user connects to the server, I add his IP to the restricted list, and start a task to unrestrict him in X seconds. restrictedIPs.add(socket.getInetAddress()); restrictTimer.schedule(new TimerTask() { public void run() { restrictedIPs.remove(socket.getInetAddress()); } }, MIN_REQUEST_INTERVAL); My problem is that at the time the task will run, the socket object may be closed, and the remote IP address won't be accessible anymore... Any ideas welcomed! Also, if someone knows a Java-framework-built-in way to achieve this, I'd really like to hear it.

    Read the article

  • detect shutdown in window service

    - by deepu
    hi, i have a windows service that get user details and save the result into log text file. and, my problem is when i shut down or log off my system, i also would like to save the time that i down my system into that log file. but, i don't know how to do that. I checked the winproc method to detect shutdown operation but i was not able to use it on window service, on googling found it can be used with forms only. how can we detect user have clicked shutdown or log off and do some action. so,please give me some idea or suggestion on that. i have used it for logoff but on log entry is made when i logoff the system protected override void OnSessionChange(SessionChangeDescription changeDescription) { this.RequestAdditionalTime(250000); //gives a 25 second delay on Logoff if (changeDescription.Reason == SessionChangeReason.SessionLogoff) { // Add your save code here StreamWriter str = new StreamWriter("D:\\Log.txt", true); str.WriteLine("Service stoped due to " + changeDescription.Reason.ToString() + "on" + DateTime.Now.ToString()); str.Close(); } base.OnSessionChange(changeDescription); }

    Read the article

  • Detect whether or not a specific attribute was valid on the model

    - by Sir Code-A-Lot
    Having created my own validation attribute deriving from System.ComponentModel.DataAnnotations.ValidationAttribute, I wish to be able to detect from my controller, whether or not that specific attribute was valid on the model. My setup: public class MyModel { [Required] [CustomValidation] [SomeOtherValidation] public string SomeProperty { get; set; } } public class CustomValidationAttribute : ValidationAttribute { public override bool IsValid(object value) { // Custom validation logic here } } Now, how do I detect from the controller whether validation of CustomValidationAttribute succeeded or not? I have been looking at the Exception property of ModelError in the ModelState, but I have no way of adding a custom exception to it from my CustomValidationAttribute. Right now I have resorted to checking for a specific error message in the ModelState: public ActionResult PostModel(MyModel model) { if(ModelState.Where(i => i.Value.Errors.Where((e => e.ErrorMessage == CustomValidationAttribute.SharedMessage)).Any()).Any()) DoSomeCustomStuff(); // The rest of the action here } And changed my CustomValidationAttribute to: public class CustomValidationAttribute : ValidationAttribute { public static string SharedMessage = "CustomValidationAttribute error"; public override bool IsValid(object value) { ErrorMessage = SharedMessage; // Custom validation logic here } } I don't like relying on string matching, and this way the ErrorMessage property is kind of misused. What are my options?

    Read the article

  • Java Detect Variable Change Using PropertyChangeSupport and PropertyChangeListener

    - by Sam
    I'm trying to print out debug statements when some third party code changes a variable. For example, consider the following: public final class MysteryClass { private int secretCounter; public synchronized int getCounter() { return secretCounter; } public synchronized void incrementCounter() { secretCounter++; } } public class MyClass { public static void main(String[] args) { MysteryClass mysteryClass = new MysteryClass(); // add code here to detect calls to incrementCounter and print a debug message } I don't have the ability to change the 3rd party MysteryClass, so I thought that I could use PropertyChangeSupport and PropertyChangeListener to detect changes to the secretCounter: public class MyClass implements PropertyChangeListener { private PropertyChangeSupport propertySupport = new PropertyChangeSupport(this); public MyClass() { propertySupport.addPropertyChangeListener(this); } public void propertyChange(PropertyChangeEvent evt) { System.out.println("property changing: " + evt.getPropertyName()); } public static void main(String[] args) { MysteryClass mysteryClass = new MysteryClass(); // do logic which involves increment and getting the value of MysteryClass } } Unfortunately, this did not work and I have no debug messages printed out. Does anyone see what is wrong with my implementation of the PropertyChangeSupport and Listener interfaces? I want to print a debug statement whenever incrementCounter is called or the value of secretCounter changes.

    Read the article

  • Detect that the onscreen keyboard has been displayed on Windows Phone 7

    - by David_001
    Simple question: How do I detect that the onscreen keyboard has been displayed on windows mobile 7? Is there an event I can add a listener to? It takes up about half the screen and I want to scroll the view up when it gets displayed... EDIT: A comment below indicates more clearly what I'm trying to do: I have a textbox input, and as the user types into it an autocomplete dropdown appears below it (like google suggest). By default, the active control (the textbox) scrolls into view when focussed, and the onscreen keyboard is directly below it. The onscreen keyboard appears in front of my autocomplete dropdown - what I want to do is make the screen scroll a little further up, so there's some room for my dropdown to be shown. The windows phone UI design guidelines say: "When the keyboard is deployed, the application should scroll to ensure the active edit control and the caret are in view". This happens fine, it's just the non-active dropdown gets hidden behind the onscreen keyboard. The guidelines also say that an application can choose to show the onscreen keyboard, and can also choose to close it. At the moment i'm stuck, and I don't think (based on my research and the replies to this question) that it's possible to detect that the onscreen keyboard has been displayed. I'm moving my investigation to see if it's possible to determine the "visible area" of the page (width & height in pixels for example), and combine this with an onfocus for the textbox... not sure if this will prove fruitful though.

    Read the article

  • Rewriting Live TCP/IP (Layer 4) Streams

    - by user213060
    I want to rewrite TCP/IP streams. Ettercap's etterfilter command lets you perform simple live replacements of TCP/IP data based on fixed strings or regexes. Example: if (ip.proto == TCP && tcp.dst == 80) { if (search(DATA.data, "gzip")) { replace("gzip", " "); msg("whited out gzip\n"); } } if (ip.proto == TCP && tcp.dst == 80) { if (search(DATA.data, "deflate")) { replace("deflate", " "); msg("whited out deflate\n"); } } http://ettercap.sourceforge.net/forum/viewtopic.php?t=2833 I would like to rewrite streams based on my own filter program instead of just simple string replacements. Anyone have an idea of how to do this? Is there anything other than Ettercap that can do live replacement like this, maybe as a plugin to a VPN software or something? The rewriting should occur at the transport layer (Layer 4) as it does in this example, instead of a lower layer packet-based approach. Thanks!

    Read the article

  • Detect some conflictive characters in a string with javascript

    - by FranQ
    Hello. I have a file input in a form that uploads a mp3 file, but I´d like to detect conflictive characters to my system in the filename, like ! @ or any other. All codes I´ve found replace these characters, but I just want to detect them to alert the user. I think it will be easy with regular expressions, but I dont know about them. I´m using jquery/javascript. Thanks in advance for your help Edit to improve my problem description: I´m working in a CodeIgniter application that allows user to upload mp3 files to the server. I use jQuery to manage client side forms. The CI upload class converts spaces in the file name to underscores and everything works. But testing the application I uploaded a mp3 file with a (!) in the name, and I got troubles with it. I just want to insert a javascript conditional before the file is uploaded to evaluate if the user´s filename contains a (!) (or any other I´d like to add later) to ask for the file to be renamed if it does.

    Read the article

  • Why do we use to talk about addresses and memory of variable in C?

    - by user2720323
    Why do we use to talk about addresses and memory of variable in C, where in other languages (like in Java, .Net etc) we do not talk about variable address and memory in a program, we will directly use the variables. But in C Language we are listening the word address and memory. How to explain this? I hope C is high level language designed over the assembly language. So C is a thin layer over assembly language (in assembly language we will use memory locations to store a variable and track a variable). But in other languages these addresses and memory related things are wrapped in that specific language, so that we will not listen these words.

    Read the article

  • pfSense routing between two routers with shared network

    - by JohnCC
    I have a network set-up using two pfSense routers arranged like this:- DMZ1 WAN1 WAN2 DMZ2 | | | | | | | | \___ PF1 PF2___/ | | | | \___TRUSTED___/ Each pfSense router has its own separate WAN connection, and a separate DMZ network attached to it. They share a common TRUSTED LAN between them. The machines on the trusted network have PF1 as their default gateway. PF1 has a static route defined to DMZ2 via PF2, and PF2 has a static route to DMZ1 via PF1. There is NAT to the WAN but internal networks (DMZ1/2 and TRUSTED) use different RFC1918 subnets. I inherited this arrangement, and all used to work fine. I made a config change to PF1 (relating to multicast), and machines on DMZ2 suddenly could not talk to TRUSTED. I rolled the change back, but the problem persisted. What I guess you'd hope would happen is that TCP packets would go DMZ2 - PF2 - TRUSTED and on return TRUSTED - PF1 - PF2 - DMZ2. That's the only way I can see it would have worked. However, PF1 drops the returning packets. I've verified this using tcpdump. I've worked around this by adding static routes to DMZ2 via PF2 to the servers on TRUSTED, but some devices on there do not support static routes so this is not ideal. Is there way to make this arrangement work decently, or is the design inherently flawed? Thanks!

    Read the article

  • Configuring two subnets with two NICS. Access from a NAS to the internet

    - by archipestre
    I am having trouble configuring my NAS. I have a DSL router with WIFI (192.168.1.1) in my flatmates room. In my room I have a server with two NICS: 1) wlan0 (192.168.1.2) that connects to the DSL router via wireless 2) em1 (192.168.0.1) that connects to the NAS (192.168.0.20) with a crossover cable. I have Fedora 17 and I have enable packet forwarding. My IP configuration is as follows: WLAN0 inet 192.168.0.1 netmask 255.255.255.0 broadcast 192.168.0.255 EM1 inet 192.168.1.2 netmask 255.255.255.0 broadcast 192.168.1.255 My routing table looks like: Destination Gateway G enmask Flags Metric Ref Use Iface 0.0.0.0 192.168.1.1 0.0.0.0 UG 0 0 0 wlan0 192.168.0.0 0.0.0.0 255.255.255.0 U 0 0 0 em1 192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 wlan0 I have enable a static route in the DSL server: Status Network Destination Subnet Mask Interface Gateway Remove Edit Active 192.168.0.0 255.255.255.0 LAN 192.168.1.2 From my server I can ping the DSL router and the NAS. From the NAS I can ping both NICS of the server. However the NAS is unable to ping the DSL router or any address in the Internet. Any idea of what is wrong. Thank you in advance

    Read the article

  • Detect when mouse leaves my app

    - by user593747
    Hello I am creating an app in win32 that will display the x, y position(In screen coords) of the mouse whereever the mouse is (inside my app client/NC area & outside). I am at the stage where I want to detect when the mouse leaves my application completely. I have written a simple win32 app that should detect & notify myself when the mouse leaves my app, BUT its not working, I never receive the messages WM_MOUSELEAVE & WM_NCMOUSELEAVE. What do you think is wrong? Am I using the wrong win32 functions? // Track Mouse.cpp : Defines the entry point for the application. // #include "stdafx.h" #include <windows.h> #include <vector> #include <string> #include <cstdlib> static HINSTANCE gInstance; // Globals // enum MouseStatus { DEFAULT = 50001, LEFT_CLIENT, LEFT_NCLIENT }; static MouseStatus mouseState = DEFAULT; static COLORREF bkCol = RGB(0,255,255); // Functions List // BOOL TrackMouse( HWND hwnd ) { // Post: TRACKMOUSEEVENT mouseEvt; ZeroMemory( &mouseEvt, sizeof(TRACKMOUSEEVENT) ); mouseEvt.cbSize = sizeof(TRACKMOUSEEVENT); mouseEvt.dwFlags = TME_LEAVE | TME_NONCLIENT; //mouseEvt.dwHoverTime = HOVER_DEFAULT; mouseEvt.hwndTrack = hwnd; return TrackMouseEvent( &mouseEvt ); } LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch(msg) { case WM_CREATE: { // Track mouse so I can be notified when it leaves my application (Client & NC areas) BOOL trackSuccess = TrackMouse( hwnd ); // Returns successful, so I correctly track the mouse if ( trackSuccess == 0 ) { MessageBoxW( hwnd, L"Failed to track mouse", L"Error", MB_OK|MB_ICONEXCLAMATION ); } else MessageBoxW( hwnd, L"Tracking mouse", L"Success", MB_OK|MB_ICONEXCLAMATION ); } break; case WM_MOUSELEAVE: { // I never receive this message // Detect when the mouse leaves the client area mouseState = LEFT_CLIENT; bkCol = RGB(50,50,50); InvalidateRect( hwnd, NULL, true ); } break; case WM_NCMOUSELEAVE : { // I never receive this message // If the mouse has left the client area & then leaves the NC area then I know // that the mouse has left my app if ( mouseState == LEFT_CLIENT ) { mouseState = LEFT_NCLIENT; BOOL trackSuccess = TrackMouse( hwnd ); if ( trackSuccess == 0 ) { bkCol = RGB(255,255,0); MessageBoxW( hwnd, L"On WM_NCMOUSELEAVE: Failed to track mouse", L"Error", MB_OK|MB_ICONEXCLAMATION ); } else MessageBoxW( hwnd, L"On WM_NCMOUSELEAVE: Tracking mouse", L"Success", MB_OK|MB_ICONEXCLAMATION ); InvalidateRect( hwnd, NULL, true ); } } break; case WM_ACTIVATE: case WM_MOUSEHOVER: { // The mouse is back in my app mouseState = DEFAULT; bkCol = RGB(0,255,255); InvalidateRect( hwnd, NULL, true ); } break; case WM_PAINT: { HDC hdc; PAINTSTRUCT ps; hdc = BeginPaint( hwnd, &ps ); SetBkColor( hdc, bkCol ); Rectangle( hdc, 10, 10, 200, 200 ); EndPaint( hwnd, &ps ); } break; case WM_CLOSE: DestroyWindow(hwnd); break; case WM_DESTROY: PostQuitMessage(0); break; default: break; } return DefWindowProc(hwnd, msg, wParam, lParam); } int WINAPI WinMain(HINSTANCE gInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { WNDCLASSEX wc; HWND hwnd; MSG Msg; wc.cbSize = sizeof(WNDCLASSEX); wc.style = 0; wc.lpfnWndProc = WndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = gInstance; wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = (HBRUSH)(DKGRAY_BRUSH); wc.lpszMenuName = NULL; wc.lpszClassName = L"Custom Class"; wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION); // if registration of main class fails if(!RegisterClassEx(&wc)) { MessageBoxW(NULL, L"Window Registration Failed!", L"Error!", MB_ICONEXCLAMATION | MB_OK); return 0; } hwnd = CreateWindowEx( WS_EX_CLIENTEDGE, L"Custom Class", L"App Name", WS_CAPTION|WS_MINIMIZEBOX|WS_VISIBLE|WS_OVERLAPPED|WS_SYSMENU, CW_USEDEFAULT, CW_USEDEFAULT, 600, 500, NULL, NULL, gInstance, NULL); if(hwnd == NULL) { MessageBoxW(NULL, L"Window Creation Failed!", L"Error!", MB_ICONEXCLAMATION | MB_OK); return 0; } ShowWindow(hwnd, nCmdShow); UpdateWindow(hwnd); while(GetMessage(&Msg, NULL, 0, 0) > 0) { TranslateMessage(&Msg); DispatchMessage(&Msg); } return Msg.wParam; }

    Read the article

< Previous Page | 94 95 96 97 98 99 100 101 102 103 104 105  | Next Page >