top -H will show threads it will show forked by default.
top -H will show threads it will show forked by default.
What shows when you type
route -n
after running your script?
I have used the following before
#!/bin/bash
$IP="192.168.1.12"
$ROUTE="192.168.1.1"
ifconfig eth0 inet $IP netmask 255.255.255.0
route add default gw $ROUTE
I would personally recommend gentoo, I know asking any question along the lines of which distro is best is almost like starting a religious discussion.
The pros for using gentoo are:
1) If set up correctly it can be a little faster than any other distro out there
2) It isn't designed for any specific use you configure it with the apps you need for a particular purpose
3) You only install what you need and nothing else
4) If you can get gentoo installed and working correctly you will learn more about linux than you ever thought possible.
Within top try P or M to sort by cpu and memory respectively
If you do decide you want to store the image in a database (there are circumstances) then use a blob datatype.
Yeah I agree the C version would perform better the problem I have is application development time, I only 1 month to develop a very large application consisting of multiple script and programs, if the perl version of c-tree will perform acceptably then I can use that rather than C.
Hi All
I am writing an application for work that will be distributed across about 200 servers, installing is going to be a big enough pain but what I am looking to do is ensure that after the application is installed it can doing a daily check against a master directory at a seperate location and check for file differences, if it finds the difference it will download the altered file and put it in place.
It should work in a similar way to rsync but be a lot less powerful, I know I could write something to do this fairly quickly but I was wondering if anyone knew of a library I could use? The problem I have is that I have a lot to do for this entire app and only about a month before it has to be deployed, I am trying to use existing code where possible.
Any suggestions appreciated.
Thanks
Ben
I am writing an application to interact with a Faircom c-tree database, there will be thousands of entries in the database I am trying to decide if I should impliment in perl or C++
Has anyone used Perl to interact with c-tree databases? What kind of perform have people got doing this and how stable has it been?
Some of the problems arise when the programmer has gone on, to another position and code was not annotated well. The university can find hundreds of candidates for MS ACCESS, but is that the same for MySQL?
Of course it is, there is always people available to fix any problem with any system, especially now that MySQL has become such a major competitor in the database market.
Now when the project gets huge and gets out of hand, migration to MS SQL server is seamless. Smooth transition path. Seen it, Done it. Plus MS ACCESS has VBA behind it to create complete VBA applications, without having to buy additional tools. However you can get VB6 if more strength is needed. Where the application client can be distributed over a network.
But when a project gets huge with MySQL you can scale the project quite well, especially with the more recent versions which support distributed transaction. MS Access may have VBA behind it and you can pay extra for VB6 but that is a pretty weak arguement, MySQL is opensource it has libraries to be supported by just about every programming language there is, free and none free, you can use PHP, Perl, Python, Ruby, C/C++. Java, Lisp, the list goes on and on, plus most of these are cross platform, and just about every language I mentioned will out perform VB6 in everyway.
SELECT is SELECT indeed but lets face it MS Access only supports a partial subset …
All these messages and no one mentioned old reliable xv :op
Can anybody help me... I was task to get version of the linux that we are using, but I dont know what command to use to show version of our linux...
uname -a
CSGAL:
UNIX isn't always open source, there is still a few versions of true UNIX operating systems that don't have the source code open to the public until recently this included Sun Solaris (version 10 they opened their code) but still includes AIX and HP-UX.
VISUAL=vi
FUPATH=/usr/local
export FUPATH#Setup for VE
VEPATH=/usr/local
export VEPATH
VVTERM=aixterm#Below is magic code to enable command line editing. Up/down arrows retrieve previous commands. Left/right move in command line, backupspace to delete.
#
set -o emacs
set -o ignoreeof
alias __A='^P'
alias __B='^N'
alias __C='^F'
alias __D='^B'
This should work in linux, since korn is what does the work in this instance basically if ksh can interprete this in AIX it should work in linux, unless you are using pdksh (public domain korn shell) which isn't entirely compatible with ksh93 (but should be 100% compatible with ksh88).
I also use korn as my default shell it is a lot more powerful that bash and all the bash derivatives (tcsh, zsh)
Worked like a charm I just tested it on my development machine and the height works in both ie and firefox, I had to make a slight alteration to get it looking good on IE.
document.getElementById('leftbar').style.height=
document.getElementById('rightbar').style.height=
(document.getElementById('maincontent').offsetHeight + 10)+"px";
Extra 10px added on and it looks great.
Thank you so much for the help.
Ben
Awesome I will experiment with that, do you know if it is cross browser capable? Or will I need to play with it a little?
Thanks so much for the pointers I will play with it this evening.
Ben
The problem with xhmtl, css, and height, is that percentage heights refer to the percetange of the containing element. The parent element is "body". So, you have to give the body tag a height of 100%, as well as all child tags.
I was looking at this and experimented with setting:
html,body {
min-height: 100%;
height: 100%;
}
However, this seems to only take into account the screen height not the height of the elements contained within the screen.
Hi All
I am hoping someone can help me out since this is driving me nuts.
On my site I have 3 columns:
|sidebar| content |sidebar|
What I want to do is have the height of the 2 sidebars controlled by the height of the content. So instead of:
|side| content |side|
| | content |___ |
|___ | content
content
I have:
|side | content |side |
| | content | |
| | content | |
| | content | |
This hasn't been a problem so far I was working with fixed length heights of 700px but now I have content that is getting bigger than the 700px limit and the just looks bad with the side bars not matching the rest of the content.
The site is: www.geekserv.com
If anyone can give pointers I would appreciate it. Please note I don't want to end up using tables or frames this site has to remain 100% xhtml and css.
Thanks in advance for any help.
Ben
PERL kicks major ass. If you are a UNIX system administrator, PERL can be your best friend.
That is, as far as scripting, why bother with ksh, bash scripting when you can do perl.
I agree perl does kick ass, it is in my opinion the best scripting language there is (python affectionados need not flame it is just an opinion), however, this said shell languages do have an important place, and are very useful to Unix Sys admins, I used to manage a medium sized solaris, bsd and linux network, and I would never have been able to maintain the network on perl alone. Different tasks require different languages, for example a script to alter a network interface is a very simple task using a shell script it becomes more complex when using perl.
Perl is a great language for most tasks and a language that it is possible to do just about anything in, however, just because you can do it doesn't mean it is the right tool for the job, at perl.com at the moment they are doing a series of articles on writing an openGL 3D engine in perl, it is a nice fun thing to do but in the real world if you are going to write a 3D engine a better tool for the job would be C/C++.
Just my 2 cents worth
Ben
Hi everyone
Out of interest what windows managers are people running and why?
I use fvwm2 because it is so light and fast but with powerful configuration options that let me set my desktop up to look and act in a way that allows me to work faster and more efficently. I have made my own toolbar using configuration files and everything is done with keyboard shortcuts.
I used to use fluxbox but found it a little too lightweight for my needs and before that I used enlightenment I found that to be a little bit to bulky with not enough configuration options.
Anyone else want to offer a favourite and the reasoning behind it?
Ben
Gentoo is a great distribution for a programmer, of course everyone will say that about their personal favourite distro, however, my "opinion" is that gentoo is put together in a way that appeals to the logic of a programmer, it is the easiest distro I have used because most of the time it fits with my way of thinking, also it only has what is needs and what you decide it should have, it doesn't install a thousand apps you will never use (unless you tell it to).
HTH
Ben
It sounds like you changed
sprintf(files_to_open, "/usr/bin/ksh %s", filename);
to
sprintf(&files_to_open, "/usr/bin/ksh %s", filename);
because that would be a char**, not a char*. Possible?
Strangely enough no I didn't touch the sprintf() I just changed the declaration of file_to_open.
Ben
files_to_open has no space reserved for it. You declared it as a char* but didn't 'new' it. So do one of these two things:
char* files_to_open = new char[ kMaxFileSize ]; // don't forget to delete it!
-or-
char files_to_open[ kMaxFileSize ];
Damn you are good lol:
char files_to_open[ kMaxFileSize ];
Causes failure to compile:
shell_interp.cpp: In member function `int Shell_Interp::runshellscript(char*,
std::string&)':
shell_interp.cpp:31: error: cannot convert `char**' to `char*' for argument `1'
to `int sprintf(char*, const char*, ...)'
shell_interp.cpp:33: error: cannot convert `char**' to `const char*' for
argument `1' to `FILE* popen(const char*, const char*)'
However, char* files_to_open = new char[ kMaxFileSize ]; is perfect gets rid of the segfault completely.
I hate to impose further but any chance you could give me an indication as to why this happened? I would like to learn why this works for future reference instead of just that it does :D Thanks
Ben
Windows - Firefox
Linux - Firefox
FreeBSD - Firefox
IE is too insecure, I recently installed firefox on wifeys computer too.
Mozilla too much for what I need
Opera too pretty and if I want mouse gestures I will download the XPI thank you very much.
Firefox rocks for my needs minimal, excellent rendering very standard compatible. I do have a love for lynx and links though.
Oh and konquer is okay except I hate to use KDE if I want to slow down my computer I will downgrade the processor, throw out the memory and corrupt my own drives thank you very much :lol:
Hi guys
It has been quite a long time since my last post, but I am having some very weird behaviour on a program I am writing and I was hoping to get a little community feedback ;)
I am writing a class that basically opens a pipe to ksh runs a script gets the results and passes it back to the main program, the weird thing is that as the program terminates it segfaults I know it is related to the class that includes popen but I can't figure out why it is happening:
This is the popen class:
cpp
#include <iostream>
#include <cstdlib>
#include <stdio.h>
#include <string>
#include "shell_interp.h"
using namespace std;
Shell_Interp::Shell_Interp()
{
}
Shell_Interp::~Shell_Interp()
{
}
int Shell_Interp::runshellscript(char *filename, std::string& returnme)
{
FILE *kshfd;
char line[200]; // Returned values shouldn't be more than char
char *files_to_open;
sprintf(files_to_open, "/usr/bin/ksh %s", filename);
if( (kshfd = popen(files_to_open, "r")) == NULL )
{
return 1; // Damn file descriptor is invalid
}
fgets( line, sizeof(line), kshfd); // Get line not in a loop cause we know the output
std::string return_result(line); // Convert to string to return
returnme = return_result; // Return this
pclose(kshfd); // Close file descriptor
return 0;
}
h
#ifndef SHELL_INTERP_H
#define SHELL_INTERP_H
#include <string>
/**
@author Ben Maynard
*/
class Shell_Interp{
public:
Shell_Interp();
~Shell_Interp();
int runshellscript(char *filename, std::string& returnme);
};
#endif
And this is the calling code in the main function (sorry it is very dirty at the moment it is …
Hi Dave
I kinda figured there wasn't a sort() algorithm on map<> but I was hoping that maybe someone had written some efficient code to do a sort, and if so if they could give a few pointers on how it is achieved.
Thanks
Ben
Does anyone know of a good way to sort an stl map?
I have something like the following example:
#include <iostream>
#include <map>
#include <algorithm>
int main()
{
map<int, float> map_to_sort;
// Populate the map with between 20 - 2000 elements
map_to_sort.sort();
}
Obviously I am aware that map<> doesn't have a sort function :op so does anyone have a quick method of sorting through a map?
From the best I can see I am going to have to manually iterate through all elements of the map and compare and move to a seperate map, I am hoping there is a better solution than this since that seems like a wasteful use of CPU time, this is for a searchengine project I am working on and as can be expected time is critical in this application, especially considering I actually need to sort through 3 seperate maps.
Any help would be really appreciated.
Best regards
Ben
What code are you actually using to fetch the ID on the next page?
Ben
From the look of the code on the next page:
<?php echo $ID; ?>
Should work.
HTH
Ben
Solaris is also a decent price last time I looked a month or so ago the full solaris media kit (books, install, oracle, extra software) cost $89, if you wanted to save money you can just download the ISO's for $20. Solaris is Unix, it is very powerful and fairly easy as unix variants go, however, it is poorly supported on x86 platforms you have to have specific hardware, on the other hand solaris 10 is coming out really soon and that has much better hardware support.
I only mention it to show that not all unix variants are over priced, in reality for a new user I would recommend freebsd or linux, in terms of linux distributions, I like gentoo but that is a more advanced distro for a new user I always recommend suse simple easy to use and very powerful, once you are familiar you can always change distros to something more advanced, slackware, debian (debian isn't for new users, debian is mostly aimed at more advanced users), gentoo (in my opinion the best since everything can be compiled from source allowing you to size every possible optimisation from your system).
HTH
Ben
I have been tring for a month now to figure out why I can't program my site to open field information from a link that looks like http://www.blablabla.com/test.php3?ID=2
I can't seem to figure out how to open just the field thats ID is = to 2.
If anyone can help I would be greatful. Thank you.
-Specdro
How are you trying to access the data? Do you have a code example?
Ben
i under stand the basics and they guy now knows i wanna help him so he got some 1 to teach me php
<html> <head> <title> hey world </title> </head> <body> <?php print"hey"; //what up? ?> </body> </html>
is this right?
Slight alteration I don't know if it makes a difference to the interpreter but for the sake of readability:
<?php print "hey";
// Have a space
?>
Open notepad, paste your code in. Click save as, scroll to the folder which you want to save to, type in hey.php in file name and click save.
And change Save As Type to all files not txt
it wasent there every1 was telling me that it is .php no . txt on the end but when i load it thats what happened .php.txt
Yes that is because notepad often saves it with the .txt extention you need to remove that.
Ben
i saved my txt file as hey.php and i used a ftp on lycos to bring it up and it say hey.php.txt and it wont open whats wrong? :confused:
First I don't know if lycos supports php but unless you have a paid account I doubt it and secondly, you have the wrong file name it should be hey.php not hey.php.txt you need to get rid of the .txt at the end.
HTH
Ben
lillafan i tried what u said andit does the same thing and i dont know to use the program it game me to write it or what i dont even know what the thing is i downloaded but i did hope its not a hack or any thing but im still lost
Don't worry it isn't a hack, you are just not using it in the right way, php scripts need to be parsed by the php executable in order to work correctly, there is text editors you can use that will allow you to see the output correctly:
However, the best way is to locally install apache and php so you can test it locally here is a link to a website that explains how to install, apache, php and mysql for windows:
If you follow the instructions at the site listed above you will be able to go to a webserver located on your machine by putting:
Into internet explorer or whatever browser you happen to be using.
HTH
Ben
It should display in a browser as:
<html>< head >< title > php test< /title > < /head >
< body >
hello world<P>
< /body></html>
You will need to save the file with a .php extention, and in order to correctly display output you will need php installed, if you are on windows you can download precompiled binaries of apache from apache and precompiled binaries of php from
php
It doesn't really matter what editor you use, but I would suggest a plain text editor ie notepad since wordpad and word etc, can add unwanted characters.
Also as a side point you don't need to have the gaps in the html ie:
< body >
Would be better displayed as:
<body>
Also when adding code in the forum using the [code][/code] tags makes it easier to read.
HTH
Ben
Hi everyone,
why don't you have a look at my other response in the c++ section entitled c++ dying a slow death. On the most common languages i would recommend you to learn basic, C# and java(very good alternative to c++)Yours Sincerely
Richard West
I would disagree with this, it is something covered in several other threads about paths to programming and stuff. Basic is a dead language, learning to program by using it is a waste of time, I would recommend learning using a language that at least still has some use in real world environments, ie, perl, c, visual basic (if you must), pascal (although it is mostly dead, delphi as a better alternative).
I don't think C++ will ever die completely, and I don't think Java will replace it, both language have their place and will be required even if it is just to maintain old applications, if C++ is the language you want to learn I recommend getting a couple of good books of the top of my head the best I have found are, Practical C++ Programming, published by O'Reilly and The C++ Programming Language, follow a few of the examples in the books, and then play, figure out something you would like to do and do it. Also if you are just beginning there is no need to drop hundreds of dollars on visual c++ I would recommended bloodshed dev-c++ for windows or even better g++ for unix environments.
HTH
…A couple of years ago I was writing a program to do just this, send out the monthly news letter for the ecommerce company I was working for. I wrote it in C and linked to libesmtp, it was a very easy task, perhaps you should look at doing something like this? The application I wrote read a file that had the content of the email and another file with a delimited list of names and email addresses it would then use substitution to replace keywords in the email and send it to the address, it took about a week to write and handled about 500K of addresses, it also worked in such a way that it didn't force too much load on server itself. I also had to mess about with sendmail to reduce the timeout value for none responsive addresses.
Failing that an easier solution could be to use mailman and create a mailing list that can only be posted too by the admin, this is a webbased frontend but the backend isn't.
HTH
Ben
Facts not opinions please. I've been selling and writing multi user business software with Access backends for a while. I have never, ever, ever, ever had a data corruption issue due to poor locking. It's because I use it for what it's intended to be used for. And just because it doesn't have the same features of more advanced systems doesn't make it any less good at what it does.
Actually my opinion is based on facts, if you had more carefully read my post you would have seen I have a lot of experience using all kinds of databases, this experience extends about 7 years now.
One of my more recent projects (in the past year) was to rebuild an application that had an Access backend it was written to make use of Access forms on the frontend it was using Access 2000 and never had more than 4 people connected at any given time, it was written by an "expert" in MSsql and Access, it was used for about 2 years often causing data corruption to itself when it was used, in the end just before I rebuilt the application to use MSsql and a visual basic front end (which you will notice are both Microsoft titles) it causes serious data corruption everytime it was used and this was a very critical application used to keep stock records for a middleweight ecommerce company. On reviewing the code I found it to be fine, and upon talking with …
An Access database is a database. Anything that's used to store information in a structural way is a database. Whether it's flat (stored in a file), hierarchical, network, object, or the most, popular relational, it's a database; they're all forms of storing data.
By this definition a telephone book is a database since it stores information in a structural way.
Okay to correct myself earlier yes Access is a database, however, it doesn't compare on any level to more sophisticated databases, this is based on my experiences, I have used dozens of database systems everything from GDBM, to BerkleyDB, from Mysql to Postgres, from MSsql Server to Sybase and Oracle. Access has a pathetic method of locking (in the versions that support locking) so whilst it may support concurrent connections it may not be protecting the data. Database repairs often cause even more problems.
Also I wouldn't define myself as a MS basher admittedly I prefer unix like systems I also believe MS has a place and they fill that place very well, I do, however, have a particular dislike of Access this is based on my bad experiences with it, not on my personal feelings towards microsoft, if you want a database to store your personal records or your cd collection Access fills that space well, if you plan on having more than one person accessing it at a time then Access seriously lacks in certain important errors.
I don't think C++ is a great language to begin with, I think most people should start with a procedural language and then move to object orientated.
I begin with:
pascal
delphi
c
perl
visual basic (ack)
c++
Of course everyone thinks that their route to learning was the best in the end experiment with different languages and find the one that suits you best, then go on from there, perl can be a very easy language it can also be very complex, C++ is very powerful and will let you do pretty much anything but it can be very difficult to learn, pascal is a great language to begin with since it is mostly a learning language unfortunatly it is pretty much a dead language there is very little demand for it in the real world.
Hope my 2 cents worth helps
Ben
Hi there
Perhaps this thread may give you pointers on what you are trying to do, it includes code examples for a similar question a few weeks ago:
Thread on bash searching
From what you have shown wouldn't the find command be more appropriate for you though?
ie:
find . -name filename -print
That will recurusivly (sp?) search through directories finding all occurances of the file called filename.
HTH
Ben
Wow the same year I was born!
Thanks for the help with this though I was in a real bind my boss wants this program ready for testing in 3 weeks and this was my last major obstacle (I hope) :)
Thanks again for the help man!
Ben
Chainsaw,
You are a genius man, seriously now it is working perfectly, I am very grateful, I would give you some more reputation but I already did before so it won't let me, but thanks a lot for your help.
How long have you been programming?
Thanks again very appreciative
Ben
Hmmm when I tried doing that I got the following error:
Kcache = &referenced_kcache;
cache.cpp: In member function `void g_cache::Set_Kcache_Reference()':
cache.cpp:26: error: conversion from `keyword_cache*' to non-scalar type 'keyword_cache' requested
or:
g_cache::Kcache = &referenced_kcache;
Gives:
cache.cpp: In member function `void g_cache::Set_Kcache_Reference()':
cache.cpp:33: error: request for member `find_keyword' in `
this->g_cache::Kcache', which is of non-aggregate type `keyword_cache*'
Or:
keyword_cache Kcache = &referenced_kcache;
Gives:
cache.cpp: In member function `void g_cache::Set_Kcache_Reference()':
cache.cpp:26: error: conversion from `keyword_cache*' to non-scalar type `keyword_cache' requested
Kcache is a pointer, so you need -> rather than .
caches.Kcache->find_keyword(word);
That will allow it to compile but it causes a segfault when it does compile, which is interesting since if I use the actual class that is pointed to it runs fine, it is only when I use the pointer class that it will segfault.
Ben
Okay I am having a bit of a problem now, this is basically the test class I have written:
Header:
class g_cache{
public:
keyword_cache* Kcache;
keyword_cache referenced_kcache;
SKU_cache Scache;
void Set_Kcache_Reference(void);
public:
g_cache();
~g_cache();
};
Main:
g_cache::g_cache()
{
g_cache::Set_Kcache_Reference();
}
g_cache::~g_cache()
{
}
void g_cache::Set_Kcache_Reference(void)
{
referenced_kcache.read_output_file();
keyword_cache Kcache = referenced_kcache;
string word = "black";
cout << "Test1" << endl;
referenced_kcache.find_keyword(word);
cout << "Test2" << endl;
Kcache.find_keyword(word);
}
This bit works when I initalise the class the output is correct both times.
However:
g_cache caches;
string word = "black";
caches.Kcache.find_keyword(word);
Doesn't even compile it gives the following error:
vsearch.cpp: In function `int main(int, char**)':
vsearch.cpp:293: error: request for member `find' in `caches.g_cache::Kcache',
which is of non-aggregate type `keyword_cache*'
Any suggestions.
Thanks
Ben
Chainsaw, now that looks perfect :) I am gonna start playing around with those methods now :)
As promised you have my eternal gratitude!!
Thanks again
Ben
Okay months later I have finally got around to reinstalling my OS and I included firefox 0.8 it works perfectly with the bar.
Thanks
Ben
Although I realized after posting that, what you WANTED to know was how to make a reference to a class....
AClass classInstance;
AClass *pClassInstance; // pointer to the class
AClass &rClassInstance; // reference to the classreferences are really pointers internally, but with the syntactic nicety that you don't use ->, but just use .
classInstance.SetVal(12);
pClassInstance->SetVal(12);
rClassInstance.SetVal(12);Like a pointer, a reference must refer to something:
pClassInstance = &classInstance; // pClassInstance now POINTS TO classInstance
rClassInstance = classInstance; // rClassInstance now REFERS to classInstanceA reference has no space allocated for it's object, the same as a pointer.
Okay that is looking a lot like what I was looking for, so is it possible to define the pointer (reference) to the class and then actually decide where it point it to?
ie:
class SomeClass {
public:
Aclassname actualclass;
Aclassname *pointerclass;
public:
void makepointer(void) {
pointerclass = &actualclass;
}
}
On looking at your code that looks like it is okay, which is exactly what I wanted, for the other half though, if later on I wanted to point the pointer to a different class without deleting the pointer how would I do that?
ie
void point_else_where(void) {
delete pointerclass;
pointerclass = &newactualclass;
}
As you can see I know exactly what I am wanting to do it is really all a matter of syntax, I haven't been programming C++ for long enough to have encountered a lot of this stuff.
…Hi all,
I am not sure how to explain exactly what I am hoping to do here, but I will do my best in the hopes that someone will understand.
I am writing a program that uses a cache, this cache is used with a thread that is seperate from the main program, this works perfectly, the cache is a seperate class.
Now the problem, the cache gets updated hourly from an external file, basically the method is that every minute or so the program checks the stat on the file and if the atime has altered it rebuilds the cache, now I need my thread that is using the cache to use totally transparently the new cache.
Since the building of the new cache every hour is handled by a seperate thread I can't figure out a sane method of updating the class in use by the first thread.
I have tried writing a seperate class called cache_control that works basically to build references ie:
class cache_control {
public:
Cache private_cache;
Cache public_cache;
void reinit_cache(void);
}
void cache_control::reinit_cache(void) {
private_cache.read_input_file();
Cache & pubic_cache = private_cache;
}
Please excuse the roughness of this code it is just an example of the type of thing I am attempting to do.
As you see I am making 2 caches the private and the public the public_cache is just a reference to the private_cache object and when my thread is started it is passed a reference …