If you're looking for a Linux laptop, I've heard System 76 sell a bunch of those. No idea on the quality, however. I've never seen one in person.Originally Posted by

Phrynobatrachusdoes anyone have recommendations for a laptop to program on? my budget is 400, and I don't care about screen size at all. 8 gigs of ram preferably. bonus points if it's a clean machine with no OS preloaded, as I'll be running a linux distro on it. thanks for any help!

Generally speaking, though you should check for Linux hardware gotchas before you buy. So many laptops make it difficult or near impossible to get a good Linux setup going, especially when it comes to graphics.

Your teacher was using mathematical notation. Just to convey the idea, but it had nothing to do with how to express that in codeOriginally Posted by

unknownstrangerPretty much. I was expecting something a little more complicated but I think that works. I got a little thrown off that my teacher listed an example range as [3,6].

looked them up, they seem nice but they're way out of my price range. I'll definitely check out the other potential issues though, thanks.Originally Posted by

PokemaniacIf you're looking for a Linux laptop, I've heard System 76 sell a bunch of those. No idea on the quality, however. I've never seen one in person.

Generally speaking, though you should check for Linux hardware gotchas before you buy. So many laptops make it difficult or near impossible to get a good Linux setup going, especially when it comes to graphics.

*?*

**how would you unit test what is essential a glorified CRUD**In my case right now, what I have is basically a class with RESTful mappings (HTTP verb, params, path, etc.) that will receive a JSON from a front end. This JSON is then passed on to be transformed into an entity that will be persisted in a database. And then on GETs the reverse will happen, it will fetch stuff from the DB and transform then back into a JSON and return. 90% of the stuff in the business logic classes are creating the entities and validating that stuff exists and things like that.

I know a little about how (somewhat familiar with JUnit and Mockito), but I have no idea what to test.

I find those kinds of tests mostly tedious though. I would mostly focus on testing the transformations, if anything.

Mock all of the DB calls to return either valid responses or errors. Then make calls to the rest service for various scenarios. For instance, send a valid JSON but have the mock DB call return a connection error. If your rest endpoint is supposed to send a 500 error with some kind of payload then assert that it actually happens. Do the same for any other scenario you can think of. If the JSON is transformed and validated in other business classes then writing unit tests for that should be easy. If not then you will likely need more tests that send different types of payloads to your rest endpoint and asserts responses for valid and invalid inputs are correct. I would also ensure that a misformatted JSON payload returns a proper response.So, I haven't done tests that much and want to improve. However I literally have no idea how in my current situation. So my question for you guys is,

?how would you unit test what is essential a glorified CRUD

In my case right now, what I have is basically a class with RESTful mappings (HTTP verb, params, path, etc.) that will receive a JSON from a front end. This JSON is then passed on to be transformed into an entity that will be persisted in a database. And then on GETs the reverse will happen, it will fetch stuff from the DB and transform then back into a JSON and return. 90% of the stuff in the business logic classes are creating the entities and validating that stuff exists and things like that.

I know a little about how (somewhat familiar with JUnit and Mockito), but I have no idea what to test.

I like to think in terms of "what can go wrong."So, I haven't done tests that much and want to improve. However I literally have no idea how in my current situation. So my question for you guys is,

?how would you unit test what is essential a glorified CRUD

In my case right now, what I have is basically a class with RESTful mappings (HTTP verb, params, path, etc.) that will receive a JSON from a front end. This JSON is then passed on to be transformed into an entity that will be persisted in a database. And then on GETs the reverse will happen, it will fetch stuff from the DB and transform then back into a JSON and return. 90% of the stuff in the business logic classes are creating the entities and validating that stuff exists and things like that.

I know a little about how (somewhat familiar with JUnit and Mockito), but I have no idea what to test.

JSON is malformed -- what happens?

JSON is invalid (missing required keys in the hashmap or whatnot) -- what happens?

JSON is valid but DB object throws an exception (e.g. simulating corrupt/failed DB) -- what happens?

You'll not only want to mock up the bogus HTTP requests, but you'll also want to set up a mock DB object so that the test doesn't require a live database. Hopefully your CRUD class isn't doing raw SQL queries.

So I'm probably going with mocking the DB layer and testing the expected exceptions in all the processes or just giving up on unit test for most stuff and just doing integration tests...

Thanks for the answers guys, it was quite helpful.

I have an assignment in one of my classes. Basically, it's reading a text file, storing the information, and then acting with it. Text files look like this:

Problem here is that I only want the numbers: I don't care about the letters in the first line, and I don't care about the brackets around the numbers. I need to get the numbers from this text file into a 2D array (doing matrix calculations with them, then printing results). The calculations should be no problem, but I have no fresh idea how to get the numbers into the array while ignoring everything else in the file.a, b, c, d

{{1, 0, 0, 1}, {1, 1, 0, 0}, {1, 0, 1, 1}, {0, 0, 1, 0}}

Do the text files all look the same in terms of dimensions, just that the numbers vary?Originally Posted by

CronoShotHey guys, bit of a C++ noob here.

I have an assignment in one of my classes. Basically, it's reading a text file, storing the information, and then acting with it. Text files look like this:

Problem here is that I only want the numbers: I don't care about the letters in the first line, and I don't care about the brackets around the numbers. I need to get the numbers from this text file into a 2D array (doing matrix calculations with them, then printing results). The calculations should be no problem, but I have no fresh idea how to get the numbers into the array while ignoring everything else in the file.

It's the first line (the letters) that determine the dimensions of the matrix. So my example of "a, b, c, d" would indicate that it's a 4x4 matrix, "a, b, c" would indicate a 3x3 matrix, and so on.Do the text files all look the same in terms of dimensions, just that the numbers vary?

I tried running it on different drives and my computer works fine for games and everything else. Other programs also compile fine.

C FILES:

Main: https://pastebin.com/hTGn55df

Function(s) file: https://pastebin.com/ypH5EWrS

EDIT: VARIABLE FOUND WAS IN THE WRONG SCOPE

If you just want the numbers in the second line, go through it character by character, identify each number individually and parse it using eg. the atoi or stoi function. But C++ has like fifty other ways to do this with depending on how safe, concise or legible you want to be. How are you storing your data? As raw memory or eg. in a vector container?Originally Posted by

CronoShotIt's the first line (the letters) that determine the dimensions of the matrix. So my example of "a, b, c, d" would indicate that it's a 4x4 matrix, "a, b, c" would indicate a 3x3 matrix, and so on.

Complexity of the conjecture functions is O(n^4) and you're surprised it's quickly slow? If you want to multiply the upper limit by 2, you multiply the time needed by 8.So my code is executing terribly. I compiled using gcc. When I execute the program it prints the first 400 values very quickly, still fast up to 900 and then starts slowing down but continues. It worked fine on the school computers.

I tried running it on different drives and my computer works fine for games and everything else. Other programs also compile fine.

Multiply it by 10 and the time needed is multiplied by 10000

That's normal... You have to write it completely differently, even a supercomputer will struggle quite fast (the limit depend on the power, but it will never be high)

The correct way to do this:

- compute ONCE all primes up to N using Eratosthene sieve

- keep BOTH a table containing primes and the table containing TRUE/FALSE values needed in the sieve

- to check whether x is the sum of two primes, take all primes p before x/2 (by using the first table) and check whether x-p is prime (by checking the TRUE/FALSE value in the second time at position x-p)

Eratosthene is O(n log(log(n))), so it will be bazing fast to compute all primes

Testing all values will still be slow, at O(n^2), but nowhere as slow... (for an upper bound of 1000, for example, the speed will be x1000000)

Edit: at the very least, you should be looking for divisors in isprime when i*i <= number and not i <= (number / 2), but that's a menial gain compared to other things...

Are those integers or real numbers?Originally Posted by

CronoShotProblem here is that I only want the numbers: I don't care about the letters in the first line, and I don't care about the brackets around the numbers. I need to get the numbers from this text file into a 2D array (doing matrix calculations with them, then printing results). The calculations should be no problem, but I have no fresh idea how to get the numbers into the array while ignoring everything else in the file.

As said, there's a bunch of different solution, depending on how well you want to be able to identify bad formatted files.

But if the file is properly formated, you can simply read digits, commas and ignore everything else...

Edit: Ahh you mean because first you iterate over all even numbers, and then for each even N, all primes less than N.

Well, for a fixed N there’s O(N/log(N)) primes. With this observation i get O(n log n) for the nested loop

Well, I agree that the number of operation isOriginally Posted by

cpp_is_kingWell, for a fixed N there’s O(N/log(N)) primes. With this observation i get O(n log n) for the nested loop

sum( pi(k/2) ) for even k over 1..n

where pi(k) is the prime counting function, and py(k) = Theta(k / log(k))

Problem is, I don't know what sum(pi(k)) gives. It''s obviously O(n^2), so I used that. I would like to know a more precise estimation.

But I really doubt it's O(n log(n)). k/log(k) is far too close to k, and log(k) grows infinitely slower than sqrt(n).

In another way :

sum(k / log(k)) dominates sum(k / sqrt(k)) which is equivalent to n sqrt(n) which dominates n log(k)

So, yes, it's less than O(n^2), but sufficiently close to it, I'd say, so that you'll never see a proper difference.

I suspect it's Omega(n^x) for basically any x<2... and it's not even O(n^1.9999999)

But I may be wrong, I'm bad at this kind of summing those special functions (and a couple of my own students are probably even better at it than me :/ )

Don't you have it backwards? Since pi(x) grows with log(x), pi(x)/x tends to 0 as x tends to infinity. So the number of primes you are looking through is actually very small once x is big enough. Thus it's less than O(n^k) for any k > 1?Well, I agree that the number of operation is

sum( pi(k/2) ) for even k over 1..n

where pi(k) is the prime counting function, and py(k) = Theta(k / log(k))

Problem is, I don't know what sum(pi(k)) gives. It''s obviously O(n^2), so I used that. I would like to know a more precise estimation.

But I really doubt it's O(n log(n)). k/log(k) is far too close to k, and log(k) grows infinitely slower than sqrt(n).

In another way :

sum(k / log(k)) dominates sum(k / sqrt(k)) which is equivalent to n sqrt(n) which dominates n log(k)

So, yes, it's less than O(n^2), but sufficiently close to it, I'd say, so that you'll never see a proper difference.

I suspect it's Omega(n^x) for basically any x<2... and it's not even O(n^1.9999999)

But I may be wrong, I'm bad at this kind of summing those special functions (and a couple of my own students are probably even better at it than me :/ )

edit: I think we need that not only does pi(x)/x -> 0, but pi(x)/(x^k) -> 0 for any k > 0, which is also true

Well you can sum a large quantity of very small things and still get huge results...Originally Posted by

The Friendly MonsterDon't you have it backwards? Since pi(x) grows with log(x), pi(x)/x tends to 0 as x tends to infinity. So the number of primes you are looking through is actually very small once x is big enough. Thus it's less than O(n^k) for any k > 1?

for 0<p<1, and for sufficiently high k, k / log(k) dominates k / k^p = k^(1-p)

So, after summing this over 1..n, I can see sum( k / log(k) ) dominating n^(2-p)

Random check for lower n:

blue is sum(pi(k))

green is n^1.999

(well, in any case, it proves that it's sufficiently close to n^2 for any practical use of the above algorithm at the very least)

Sorry, i meant n^2 / log(n), which is a fairly direct resultWell, I agree that the number of operation is

sum( pi(k/2) ) for even k over 1..n

where pi(k) is the prime counting function, and py(k) = Theta(k / log(k))

Problem is, I don't know what sum(pi(k)) gives. It''s obviously O(n^2), so I used that. I would like to know a more precise estimation.

I'm fine with O(n^2/log(n)), indeed.Originally Posted by

cpp_is_kingSorry, i meant n^2 / log(n), which is a fairly direct result

Though, I don't think the log(n) here matters much*... you'll deal with 4 million numbers instead of 1 million in 1h on an average computer, which is welcome, but won't turn tables.

* like O(1) and O(log(n)), or O(n) and O(n log(n)) are usually nearly the same...

Thanks a lot for this indepth feedback but I made this from what we've learned so far in the class. I appreciate it though. Ill refer to this in the future.Complexity of the conjecture functions is O(n^4) and you're surprised it's quickly slow? If you want to multiply the upper limit by 2, you multiply the time needed by 8.

Multiply it by 10 and the time needed is multiplied by 10000

That's normal... You have to write it completely differently, even a supercomputer will struggle quite fast (the limit depend on the power, but it will never be high)

The correct way to do this:

- compute ONCE all primes up to N using Eratosthene sieve

- keep BOTH a table containing primes and the table containing TRUE/FALSE values needed in the sieve

- to check whether x is the sum of two primes, take all primes p before x/2 (by using the first table) and check whether x-p is prime (by checking the TRUE/FALSE value in the second time at position x-p)

Eratosthene is O(n log(log(n))), so it will be bazing fast to compute all primes

Testing all values will still be slow, at O(n^2), but nowhere as slow... (for an upper bound of 1000, for example, the speed will be x1000000)

Edit: at the very least, you should be looking for divisors in isprime when i*i <= number and not i <= (number / 2), but that's a menial gain compared to other things...

Are those integers or real numbers?

As said, there's a bunch of different solution, depending on how well you want to be able to identify bad formatted files.

But if the file is properly formated, you can simply read digits, commas and ignore everything else...

I'm trying to print the number of items on a list. If I do something as easy as:

It prints the number 3 no problem. But when I try to print the number in a quick sentence like thisCode:

guest = ['Jake', 'Fred', 'Joey'] guest_number = len(guest) print(guest_number)

it'll give me this errorCode:

print("How many guest is it? Oh it's " + guest_number + ".")

Sorry for such a dumb question but I'm just getting the hang of Python and this is confusing me.Code:

TypeError: must be str, not int

I'm following the automate the boring stuff with python book and have a question regarding regular expressions. I'm writing the program scrape emails and phone numbers from a pdf and am getting different output than he does (watching the videos on udemy)

here's my regex followed by the output:

It's adding these u's... I learned that the u'string' means it's a unicode, but didn't find anything about the capital U's being added within the string itself.Code:

emailRegex = re.compile(r''' # some.+_thing@something.com # [a-zA-Z0-9_.+]+ --> custom char class [a-zA-Z0-9_.+]+ ##name part - custom char class, search for one or more @ #@ [a-zA-Z0-9_.+]+ #domain name part --> search for one or more ''', re.VERBOSE) Output: [u'Uricks@astate.eduU', u'Utmohajir@astate.eduU', u'Ughogue@astate.eduU', u'Urhannah@astate.eduU']

So I went to paste in an example e-mail from the document and even here it's adding the U...?

Urhannah@astate.eduU

Ughogue@astate.eduU

Any insight on why what this means is appreciated, thanks!!

I'm late, and there was a perfect answer, but just a comment... + require strings on both sides, so str is a solution, but slightly better: don't use +, use commasQuick Python 3 question and I feel so dumb I can't figure it out.

I'm trying to print the number of items on a list. If I do something as easy as:

It prints the number 3 no problem. But when I try to print the number in a quick sentence like thisCode:

guest = ['Jake', 'Fred', 'Joey'] guest_number = len(guest) print(guest_number)

it'll give me this errorCode:

print("How many guest is it? Oh it's " + guest_number + ".")

Sorry for such a dumb question but I'm just getting the hang of Python and this is confusing me.Code:

TypeError: must be str, not int

it's more efficient (sep="" is to remove spaces betweens elements)Code:

print("How many guest is it? Oh it's ", guest_number, ".", sep="")

Pretty sure it comes from the pdf, something related with underlining the mails... I'd say the regex is fine, it's an issue in the regex/data relation or the way you read the content/the pdf reader.Any insight on why what this means is appreciated, thanks!!

Sorry, I'll explain in depth a bit later... It's fine with what you now, I do it with students that have less than 4h of experience in coding, it's easy...Thanks a lot for this indepth feedback but I made this from what we've learned so far in the class. I appreciate it though. Ill refer to this in the future.

Thanks! That's the conclusion I came too as well. The e-mails were clickable links in the pdf and if I copied text from a file that did not have clickable links it worked as expected.Pretty sure it comes from the pdf, something related with underlining the mails... I'd say the regex is fine, it's an issue in the regex/data relation or the way you read the content/the pdf reader.

if you use ",' instead of "+" you can not only get it to work without the traceback but also you don't need to convert it to string then..like this..Quick Python 3 question and I feel so dumb I can't figure it out.

I'm trying to print the number of items on a list. If I do something as easy as:

It prints the number 3 no problem. But when I try to print the number in a quick sentence like thisCode:

guest = ['Jake', 'Fred', 'Joey'] guest_number = len(guest) print(guest_number)

it'll give me this errorCode:

print("How many guest is it? Oh it's " + guest_number + ".")

Sorry for such a dumb question but I'm just getting the hang of Python and this is confusing me.Code:

TypeError: must be str, not int

print("How many guest is it? Oh it's " , guest_number, ".")

I want to learn orogramming so that aside from filling holes in the appworld where I need something like this money app I can build some sellable skills outside my main career path too. Don't want all my eggs in one basket.

I am starting with c# and want to learn java as well. Is that a good start? What are some good resources? Any tips?

C# is a pretty decent way to start. It's pretty flexible. A budgeting app is not a bad place to start either as the core functionality is simple. Just don't get too bogged down in the interface design at the start.I am intending to learn to program. I am primarly interested in app development for mobile platforms like android and big data interests me too.my first program is to be a personal finance app tracking income and expenses, budgeting, and saving for the average Joe. I haven't found a really simple and intuitive app for that that really fits what I want in that type of app. It will most likely be canadian based so I can create programs for estimating pay cheques and tax returns and stuff too and have it focused. It will be a simple, intuitive soon for the average canadian Joe who wants to start managing his money.

I want to learn orogramming so that aside from filling holes in the appworld where I need something like this money app I can build some sellable skills outside my main career path too. Don't want all my eggs in one basket.

I am starting with c# and want to learn java as well. Is that a good start? What are some good resources? Any tips?

C#/.Net is great, but if you're wanting to go into mobile development, I'd try to learn Java asap. It's similar enough to C# these days and Android runs mainly off Java.I am intending to learn to program. I am primarly interested in app development for mobile platforms like android and big data interests me too.my first program is to be a personal finance app tracking income and expenses, budgeting, and saving for the average Joe. I haven't found a really simple and intuitive app for that that really fits what I want in that type of app. It will most likely be canadian based so I can create programs for estimating pay cheques and tax returns and stuff too and have it focused. It will be a simple, intuitive soon for the average canadian Joe who wants to start managing his money.

I want to learn orogramming so that aside from filling holes in the appworld where I need something like this money app I can build some sellable skills outside my main career path too. Don't want all my eggs in one basket.

I am starting with c# and want to learn java as well. Is that a good start? What are some good resources? Any tips?

So, I'd say start off with Java instead of C# to get a jumpstart on mobile development, specifically for Android, if that's where you want to go. After that, dive into C#, which will basically be a parallel move from Java, and get yourself acquainted with .NET. It seems like a lot of enterprise software is trending that route these days, ut I'm probably biased since I've been focusing on .NET these last couple years (started off learning C/C++ and then Java before transitioning to C# development).

I wasn't being passive aggressive. Also we were explicitly told to do it this way.Pretty sure it comes from the pdf, something related with underlining the mails... I'd say the regex is fine, it's an issue in the regex/data relation or the way you read the content/the pdf reader.

Sorry, I'll explain in depth a bit later... It's fine with what you now, I do it with students that have less than 4h of experience in coding, it's easy...

It's the sensible way to do things if you want to take the quick road (though I wouldn't suggest leaning coding with Java) but my heart would say learn C# and hope Android developpers come to their senses and get rid of Java ;)C#/.Net is great, but if you're wanting to go into mobile development, I'd try to learn Java asap. It's similar enough to C# these days and Android runs mainly off Java.

So, I'd say start off with Java instead of C# to get a jumpstart on mobile development, specifically for Android, if that's where you want to go.

I don't doubt that... It's just... it's hard to guess what's the background of people, and I'm really sorry when I misjudge it.I wasn't being passive aggressive.

If that's the case, it's perfectly normal it's slow, and there's little you can do about it, except some tweaks.Also we were explicitly told to do it this way.

Still, even if you don't need right now, just for the future, the idea behind efficiently computing primes (it's quite a common task if you deal with algebra):

- write 2 and all odd numbers >=3 in ascending order on a sheet of paper

- read numbers in order (they are primes), and remove multiples (they can't be primes)

done!

e.g. :

2 3 5 7 9 11 13 15 17 19 21 23 25...

2 is prime, remove multiples

2 3 5 7 9 11 13 15 17 19 21 23 25...

3 is prime, remove multiples

2 3 5 7 11 13 17 19 23 25...

5 is prime, remove multiples

2 3 5 7 11 13 17 19 23...

7 is prime, remove multiples

etc.

You actually only need to remove odd multiples of i starting with i**2

Here's a quick'n dirty solution (not memory efficient) that check if even numbers are sum of two primes

Basically, it takes less than 1 second to check half a million even numbers with this.Code:

#include<stdio.h> int main(int argc, char* argv[]) { bool* isPrime = new bool[1000000]; // can't allocate large arrays the other way int* primes = new int[1000000]; int nbPrimes = 0; // Initialize isPrime: // isPrime[i] will be true if i is prime // at the end of the sieve // // At the beginning: // - even numbers aren't -> false // - odd numbers *can* be primes -> true // - exceptions: 1 is not prime, 2 is prime for(int i=0; i<1000000; ++i) { isPrime[i] = (i%2 != 0); } isPrime[1] = false; isPrime[2] = true; // Compute primes with Erat. sieve for(int i=0; i<1000000; ++i) { // Take all numbers in order // if there's true in isPrime[i], // i is prime if (isPrime[i]) { primes[nbPrimes] = i; // Remember i nbPrimes++; // One more prime // Multiples of i are not primes // Only odd multiples above i**2 // actually need to be removed, // so only if i<sqrt(n) if (i<1000) // 1000 is sqrt(1000000) for(int m=i*i; m<1000000; m+=2*i) isPrime[m] = false; } } // Check conjecture for(int i=4; i<1000000; i+=2) { bool OK = false; int k=0; // Test all primes p <= i/2 // and check whether (i-p) is a prime while (!OK) { if (isPrime[i-primes[k]]) // We found a solution OK = true; else if (2*primes[k] >= i) { // We reached i/2 printf("The conjecture is false for %d\n", i); OK = true; } k = k+1; } } return 0; }

The problem asks me to make a function called power that takes two parameters, a and b, and determines whether a is an integer power of b. If it is, the whole thing should return True. If not, False. I'm not allowed to use ** to calculate power, and I can't use loops. I have to just use recursion.

I keep falling into the pitfall of wanting to refer back to the initial a and b values but I can't, since each recursive call that I can come up with to try entails me changing a or b. I'm really stumped. Could I get a hint?

Hint: there's no problem with changing one of the parameters - in fact that's a necessity in recursive functions. So there are a few hints:Hello again. I'm a programming scrub taking an intro CS class using Python. We're currently learning about recursion. It's really tough for me but I've been able to do most of the exercises, though one is really causing me trouble. I'd really appreciate a nudge in the right direction.

The problem asks me to make a function called power that takes two parameters, a and b, and determines whether a is an integer power of b. If it is, the whole thing should return True. If not, False. I'm not allowed to use ** to calculate power, and I can't use loops. I have to just use recursion.

I keep falling into the pitfall of wanting to refer back to the initial a and b values but I can't, since each recursive call that I can come up with to try entails me changing a or b. I'm really stumped. Could I get a hint?

* If you are having trouble thinking recursively, first write your function iteratively, i.e. using a loop. Then try to translate it into a recursive function.

* Think about your base case, i.e. your recursion function's terminating condition, and also think about how you ought to get arrive at that terminating condition (by changing one of the parameters that you pass to each function call).

* Bigger hint: You would mutate *a* as you call your recursive function, and your base case should could check: if a == b, then return True, but if a < b, return False

* Biggest hint: You mutate a by dividing it by b, so for example given a = 125 and b = 5, the first call to power() a == 125 and b == 5, the second call to power() a == 25 and b == 5, and the third and final call to power a == 5 and b == 5. Since a == b, you know that a is an integer power of b.

Failing finding a ready made solution, I'll have to implement my own. Essentially I'll just be taking the base image, adding noise to it and then adding it to the training set. That being the case, anyone have any advice for what kind of filters would be ideal/available? I'll be needing to apply as many as possible ideally to create the most iterations possible. Python3 friendly libraries is pretty much mandatory simply because I'll be having to live feed the data into the trainer instead of storing for later access. Feedback appreciated.

See some familiar faces there. Neat. I'll give it a look, but I'm resistant to change so I'm hoping some programmingGaf members stay here.Cpp King sends his regards to everyone at programming GAF. Says it's been fun and that C++ is the best language. You can find him on Slaent.

I have two QA servers, I remotely restart the second using the following C# method

Now I want to find out if the server is running or if it's being restarted. I created a method that looks at the WMI LastBootUpTime and compares it with the DateTimeNow, but that wasn't such a good idea. Since the the LastBootUpTime isn't accessible while the server is being restarted. Also tried pinging the server while it was being restarted and the ping was a success :/Code:

private static void RestartSecondServer() { Console.WriteLine("Computer details retrieved using Windows Management Instrumentation (WMI)"); //Connect to the remote computer ConnectionOptions co = new ConnectionOptions(); co.Username = @"***********"; co.Password = "*********"; ManagementScope ms = new ManagementScope("\\\\******\\root\\cimv2", co); //Query remote computer across the connection ObjectQuery oq = new System.Management.ObjectQuery("SELECT * FROM Win32_OperatingSystem"); ManagementObjectSearcher query1 = new ManagementObjectSearcher(ms, oq); ManagementObjectCollection queryCollection1 = query1.Get(); foreach (ManagementObject mo in queryCollection1) { string[] ss = {""}; mo.InvokeMethod("Reboot", ss); Console.WriteLine(mo.ToString()); Console.WriteLine("Reboot complete"); //Process.Start("shutdown", "/r /t 0"); } }

I want something that tells me in real time the server is being restarted. Mind you this is a remote server. Any ideas or suggestions? Thank you

I miss the discussions here T_T

Thread Tools | |