Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Search results for query: *

  1. newmangj

    C "tail" Functionality

    ae2k Thanks for the feedback - feel free to use the code as you need. I wrote the code such as you describe (ie that it runs from the start of the file in the absence of the position file) because that suited my needs at the time. I needed to make sure that I did not miss any records in the...
  2. newmangj

    C "tail" Functionality

    The problem with some of the previous code is that it doesn't cope when the log file is truncated (perhpas by being relegated). The code below is something I wrote to monitor a log file and report on any lines containing one of a number of search words. You should be able to extract just the...
  3. newmangj

    Extracting words from string?

    Use the strtok function to separate out the names. If you need more information please post an example of your input data. Cheers - Gavin
  4. newmangj

    change ftp port

    It depends on the ftp server you are running, in the case of ftpd use the -p command line option to specify the port to listen on, other daemons will have their equivalent, refer to the man pages for the daemon you are using.
  5. newmangj

    Storing integers with leading zeros

    stoolpigeon The numbers we are talking about here (xip or postcodes, employee ids etc a re generally a fixed, known length) Based on 30+ years of writing applications I would have thought the "load" on developers is minimal, whether they are dealing with numbers or strings the...
  6. newmangj

    Storing integers with leading zeros

    If the data you are storing is numeric in nature I cannot think for the life of me why you would want to store it as a character string instead of an integer.... Why use 9 characters per record when a single integer would suffice. The fact that the data is stored without leading zeroes should...
  7. newmangj

    Timestamp Unix v/s Windows

    Sorry but you'll find that both Windows and Unix have the concept of an epoch (although in Windows case it is "artificial". In both systems the C-based time() call will return the number of seconds since 1/1/1970. From memory some versions of DOS (the PC version not the IBM mainframe...
  8. newmangj

    mid$, left$, right$ equivalance in C.

    In addition to the strtok method which works well if there is a known delimiter (or delimiters) between the information you want you can simulate the left$, right$ etc functions by using the strncpy() function. Examples /* Copy first 6 characters */ strncpy(dest, src, 6); dest[6]=0x00; /*...
  9. newmangj

    Mirroring ports Catalyst 5500

    You may want to look at the inpkts enable addition to the command.
  10. newmangj

    TELNET - SHOULD BE SIMPLE

    An outside shot, if you have some method of tracing the LAN port that the logon attempt is coming in on you can assure yourself that the password is coming through as expected - I had a similar case some time ago where the terminal emulator being used to telnet was set to some obscure emulation...
  11. newmangj

    trying to calculate any given upcoming monday based on a timestamp

    The following line will return the date for next monday given the month day & year being placed in the appropriate places in the line, obviously you would use variables rather that hard-code as I have for testing purposes..... $next_monday=strftime("%D",strtotime("next...
  12. newmangj

    seeing the directory you are in without having to type pwd

    Within Linux I use the following: I add the following to the end of /etc/bashrc if [ $(whoami) = root ] then PROMPT_COMMAND='echo -en ^[[01\;05\;31\;40m ; echo -n $(/etc/fancyprompt) ; echo ^[[00m' else PROMPT_COMMAND='echo -en ^[[01\;33\;40m ; echo -n $(/etc/fancyprompt) ; echo...
  13. newmangj

    Removing CR/LF from a file

    Something like this will do it - you'll have to add your own error checking as required..... FILE * fptr_in; FILE * fptr_out; char sz_buffer[1024]; char * ptr; if((fptr_in=fopen("test.c","r"))==NULL) return 1...
  14. newmangj

    Application status

    You could run a script that periodically uses nmap to test whether the port is open. (nmap -p 1404). This will tell you whether the application (or any application) has opened the port for receive.It will not tell you that the "upper" layers of the logic of your code are working...
  15. newmangj

    I need help reading a file

    Please post your script in full....
  16. newmangj

    Randomization

    What about this You break the exercise into 2 parts, the first part just calculates the random number and places it into slot 0 of the array. Then you run the loop but start $i at a value of 1. <?php $highest = 30; $numads = 5; srand((double)microtime()*1000000); $random=rand(1,$highest)...
  17. newmangj

    Problems inserting data

    I know its a dumb question but does the user you are using have the authority to add records to the database?
  18. newmangj

    Randomization

    Glad to be of service. The other alternative is to only do the in_array check when the value of $i is greater than 0. In this way the $varar array would be in existance (created when $i = 0) and you would avoid a superfluous call to in_array() when inserting the 1st value into the array (where...
  19. newmangj

    Randomization

    or use the in_array() function
  20. newmangj

    Randomization

    Or instead of using a sub-loop you could use the array_search() function to check. ie. if(array_search($random,$varar)!=FALSE) then the value in $random already exists in the array and should be re-calculated. <?php $highest = 30; $numads = 5; for ($i=0; $i < $numads; $i++) {...

Part and Inventory Search

Back
Top