Comatose 290 Taboo Programmer Team Colleague

No. That's not what web-servers do. You can write a program that listens on port 80 (web port) and have that accept connections from clients. Then you can have that program send any data to any other connection.... what exactly are you trying to do?

Comatose 290 Taboo Programmer Team Colleague
#!/usr/bin/perl

$filename = "/root/file";
$var = `cat $filename | wc -l`;

print "$var";

EDIT: you shouldn't be stomping around a system as root.

Comatose 290 Taboo Programmer Team Colleague
#!/usr/bin/perl
system("cat '/something/something/something/darkside.txt'");
Comatose 290 Taboo Programmer Team Colleague

It may not be my site, but at least I follow by the rules that the owner has asked the people to follow by. How about you figure it out, and take the criticism as it was meant to be taken, and when you see other people (who could have clearly answered this question) choosing not to because it very likely is homework, do the same. Otherwise you don't bother.

Comatose 290 Taboo Programmer Team Colleague

The mistake, was that he showed no effort at all toward the assignment. He very well could be doing this as a homework assignment (and probably is, based on the nature of what the program seems to do). You basically did his homework for him, and what did he learn? He learned that he didn't have to write code, or learn the code, because someone on a forum will post it for him. You'll notice that in the announcements from Dani (developer of the site) that we only give homework to those who SHOW EFFORT. No code effort was shown here.

As far as code tags go, when you post code you can do so like this (but don't use any of the spaces... I did that to make it show up on the screen instead of being read by the system as code tags):

[ code=vb ]
your code goes here
[ /code ]

Comatose 290 Taboo Programmer Team Colleague

How 'Bout you post this in VB.NET, instead of VB 4/5/6?

Comatose 290 Taboo Programmer Team Colleague

How about not just giving him the code, but making him show effort for it parkes82. Did you read any of the posts leading up to yours? Furthermore, how about you use code tags.

Comatose 290 Taboo Programmer Team Colleague

sounds like a fun homework assignment.

Comatose 290 Taboo Programmer Team Colleague

First, you don't want your instructor to know that you simply copied the code from this web page. Getting assistance by using the page is one thing.... basically plagiarizing the code is another altogether. However, the output is correct, and the program does work.

The reason it is likely "just closing" is because you are running this through a GUI of some kind, that launches the code, and exits (hence, closing the otuput window). You can run this through a command line, or put a cin.ignore() just before the return 0; (which you don't have, but should have as the last line before the ending }). If one cin.ignore() doesn't work, try two.

StuXYZ commented: well spotted that it was a copy!!! +5
Comatose 290 Taboo Programmer Team Colleague

Even though I strongly empathize with your situation, the code that you are requesting is highly illegal, and has major moral implications as well. As the site rules (sometimes unfortunately) dictate, this type of help (even though the situation may warrant it) is forbidden on the site. I'm sorry.

ddanbe commented: Nice handling of a delicate situation. +4
Comatose 290 Taboo Programmer Team Colleague

Show me the code you have, and I can see what help I can offer once I see what effort you have applied.

Step 1. Read argv[0]. argv[0] is the name of the file
Step 2. Check that argv[0] file still exists (yeah, it should)
step 3. Open the file pointed at by argv[0]
step 4. Read the file, and display it to the screen.
step 5. Close the file, and end the program.

Comatose 290 Taboo Programmer Team Colleague

How about you don't post to three year old threads, that have already been marked solved..... dufus.

Comatose 290 Taboo Programmer Team Colleague

What code do you have so far?

Comatose 290 Taboo Programmer Team Colleague

I strongly suggest using sdl_net for your socket work. I've found it to be a very nice cross-platform socket library, with quite a bit of functionality. It has a couple of quirks, but they are minor, and easy to work around.

As A.D. Suggested you would need to connect to daniweb.com, and then choose port 80... then you should connect, but you'll have to send an http request header... however, connecting directly out without needed to use an HTTP server... unless you are trying to work on some kind of proxyish, bypass firewall rule thing. In which case, I don't see why you don't just run the server on the web port (80 or 8080) anyway.

Comatose 290 Taboo Programmer Team Colleague

Look Up Declaring Variables and
Basic I/O. That should get you on a roll.... you might even try this link for help. That first link... boy it's a doosey.

Comatose 290 Taboo Programmer Team Colleague

What code do you have done so far?

EDIT: if your answer is none... start here:

#include <iostream>

using namespace std;

int main(int argc, char **argv)
{
     // Declare Length, width, area and perimeter

     // Display message about length to user
     // Get length from user

     // Display message about width to user
     // Get width from user

     // Calculate perim
     // Calculate area

     // Show perim to user
     // Show area to user

     return 0;
}
Comatose 290 Taboo Programmer Team Colleague
#include <iostream>

using namespace std;

int kids = 0;
int pass = 0;
int score = 0;

int main(int argc, char **argv)
{
	cout << "Enter number of students: ";
	cin >> kids;

	for (int count = 1; count <= kids; count++) {
		cout << "What was student " << count << "s score? ";
		cin >> score;
		if (score > 69) pass++;
	}

	cout << "There Are " << pass << " passing students :)" << endl;

	cin.ignore();

	return 0;
}
Comatose 290 Taboo Programmer Team Colleague

What code do you have so far? Post your effort, and we may help.

Comatose 290 Taboo Programmer Team Colleague

Well, how does it look in the database file? That is, what is the format of the fields?

firstname:lastname:date:phone
firstname:lastname:date:phone
firstname:lastname:date:phone

or something more like:

id, firstname, lastname, date, phone

?

Comatose 290 Taboo Programmer Team Colleague

right now, yes. But remove a record..... then what? There will be a blank line. Now you will have to somehow shift ALL LINES to cover down for the blank.

Comatose 290 Taboo Programmer Team Colleague

How about you not post to 4 year old threads... dolt.

Comatose 290 Taboo Programmer Team Colleague

How about you do your own homework?

Comatose 290 Taboo Programmer Team Colleague

Since you didn't really specify....

#include <fstream>

using namespace std;

int main(int argc, char **argv)
{
     fstream fin;
     std::string excel_file = "c:\myfile.xls";
     fin.open(excel_file.c_str(), ios::in);

     if (fin.is_open()) {
          // excel file is opened
          fin.close();
     } else {
         cout << "Failed To Open File" << endl;
     }
}

Although, I bet you are really looking for this here.

Comatose 290 Taboo Programmer Team Colleague

While not excel specific, this should get you on your way:
http://www.daniweb.com/tutorials/tutorial51307.html

Comatose 290 Taboo Programmer Team Colleague

that depends entirely on how the data is stored in the flat file... the problem with flatfiles, is that they are sequential. So, at the very least, you are going to have to loop through the lines in the file, until you find your record, remove your record, and re-write everything before (and after) your record. That's just how it goes with flatfiles. You don't really HAVE to, you could write your code so that if it finds a blank line during processing, that it just ignores it, but you are looking at mad database bloat. If you had written the file as "binary", then you could add and remove records without having to go through each line.... but with a flat-file, you pretty much have to.

Comatose 290 Taboo Programmer Team Colleague

That's how I roll.

Comatose 290 Taboo Programmer Team Colleague

why is 'a' a pointer to a pointer?

edit: Hmmm...I see what's you're trying to do.

Comatose 290 Taboo Programmer Team Colleague
Comatose 290 Taboo Programmer Team Colleague

How 'bout you figure it out and check the code snippets section?

Comatose 290 Taboo Programmer Team Colleague

Yeah....

This is the easy way to do it, without the major headaches.... the other way to do is a little less "fluky" that is, sometimes if you are on the edge of the label, it might not always hide or something like that... try it out and see if it suits your needs. The alternative is to use an ugly mesh of API calls.

Comatose 290 Taboo Programmer Team Colleague

Sorry to back to back post (edit is now gone):

#include <iostream>
#include <cstring>
#include <vector>

using namespace std;

int main()
{
	char input[255];
	int countWrite = 0;
	int countLink = 0;
	int countDir = 0;
	string owners[255];
	char *s;
	char *result = NULL;
	string pid,perm,dir,owner,group,size,date,file,mtime;
	char d,l,w;
	
	while (cin.getline(input,255,'\n'))//read lines from output of unix cmd ls -ali
	{	
	
		vector<string> parts;
		std::string tmpstr(input);
		if (tmpstr.substr(0, 5) == "total") continue;	

		s = input;	

		result = strtok(s, " ");

		while (result != NULL)  {
			if (result != "" && result != " ") {
				parts.push_back(result);
			}

         		result = strtok(NULL, " ");
     		}


		pid = parts[0];
		perm = parts[1];
		dir = parts[2];
		owner = parts[3];
		group =parts[4];
		size = parts[5];
		date = parts[6];
		mtime = parts[7];
		file = parts[8];
		

		cout << "pid: " << pid << endl;
		cout << "perm: " << perm  << endl;
		cout << "dir: " << dir  << endl;
		cout << "owner: " << owner << endl;
		cout << "group: " << group << endl;
		cout << "size: " << size  << endl;
		cout << "date: " << date  << endl;
		cout << "time: " << mtime << endl;
		cout << "file: " << file << endl;


		// I dunno about the rest of your code, but it works up to here
		// This is a hack job... I didn't want to have to rewrite your 
		// entire code, so I made it work with what you have.

			
		if (perm == "d*")//count directories
			countDir++;

		if (perm == "l*")//count …
Comatose 290 Taboo Programmer Team Colleague

Your while loop, for loop, and cout's, you don't seem to think are part of your int main?

anyway, have you looked at the output of ls -ali? I see the distance between some of the columns in only one space.... but output of some of the others is not simply 1 space, but varies based on the length of the other column, and so forth and so on.

edit: oh, and don't forget the first line that is output: total 1532 (some number, mine is 1532).. yeah, you might want to discard that first read.

Comatose 290 Taboo Programmer Team Colleague
Comatose 290 Taboo Programmer Team Colleague

Probably is, you've pointed to VB.NET, this is vb 4/5/6

Comatose 290 Taboo Programmer Team Colleague

Implicit cast to long long int seems to work....(at least on Fedora 8 with g++)

edit: forgot about precision... discard. (you may need to use GMP, if in linux)

Comatose 290 Taboo Programmer Team Colleague

Put this in your form or module:

Public Function Check_Key(Key As String) As Boolean
     Dim wsh
     Set wsh = CreateObject("WScript.Shell")
     On Error GoTo nokey ' I rarely, If ever use GoTo... I hate sloppy code
                         ' however, this seems to warrant its use... so be it.
     
     keyval = wsh.regread(Key)
     If keyval <> "" Then
           Check_Key = True
           MsgBox "cool"
     End If

     Exit Function

nokey:
     Check_Key = False
End Function

Then use it like this:

dim KeyExists as boolean
KeyExists = Check_Key("HKLM\software\microsoft\windows\currentversion\run\TBellExe")
msgbox KeyExists
Comatose 290 Taboo Programmer Team Colleague

Other than you have two mains ;)

you need to change the [ ] around the return value of strtok to ( )... don't count on it showing you anything though.... (you have no data output)

Comatose 290 Taboo Programmer Team Colleague

It is too late.... this thread is like, 2 years old man, and the OP said he got it working.....

Comatose 290 Taboo Programmer Team Colleague
shell "cmd.exe /c dir \"
samir_ibrahim commented: Very cool one command line +1
Comatose 290 Taboo Programmer Team Colleague

First off all, how about you not post to really old threads....
secondly, how about you don't post the same thing twice...

Comatose 290 Taboo Programmer Team Colleague

*Mumbles something about multiple exit points*

Comatose 290 Taboo Programmer Team Colleague

By the beard of Zeus, I'm guessing it doesn't know what kind of database your .xsd is..... how was it made?

Comatose 290 Taboo Programmer Team Colleague

Very good, you can mark this thread as solved.

Comatose 290 Taboo Programmer Team Colleague

When dealing with servers (which are usually important to the company) the safest way to move the database, is to duplicate it first.... then later remove it from the source. So while you are right, moving and duplicating are different.... would you think it is wise from an administration point of view to move the data? No. You duplicate the data... then if everything goes well, you delete the old data. So, assuming we are people who have server administration experience (could be a big assumption), I'd say it's a safe bet to not even talk about the act of "moving" data directly.........

Comatose 290 Taboo Programmer Team Colleague

You have to first make the function in bash... like I did above. Once you make the new function, then you can do "newpath /". Also, you have to make sure you make the function each time you load a new terminal or whatever (or make sure the startup files for those programs have that in it)

Comatose 290 Taboo Programmer Team Colleague

Ok... and the problem you are having is?

Comatose 290 Taboo Programmer Team Colleague

...

Comatose 290 Taboo Programmer Team Colleague

Try not to back to back post... it's bad etiquette (though sometimes necessary). The better alternative is to edit your post within the grace-period provided by the site.

Comatose 290 Taboo Programmer Team Colleague

....

Comatose 290 Taboo Programmer Team Colleague

Yeah, let's not post to threads that are nearing a year old.....