startup program deleting shutdown? Need help

This is a discussion on startup program deleting shutdown? Need help within the Linux Programming forums, part of the Platform Specific Boards category; Alright, I am pretty new to Linux but I am going to learn it never the less even if it ...

  1. #1
    Registered User
    Join Date
    Jul 2005
    Posts
    2

    startup program deleting shutdown? Need help

    Alright, I am pretty new to Linux but I am going to learn it never the less even if it kills me. Currently I am trying to run a C based program and am having trouble with the startup.startup file (the file which boots up the program. What it is doing, it is removing the shutdown file and moving it to a log (I think) but not providing a replacement. Here is the startup code:

    Code:
    #!/bin/bash
    # Written by Furey.
    # With additions from Tony and Alander.
    
    # Set the port number.
    port=4204
    if (test "$1" != "" ) 
        then port="$1"
    fi
    
    # Change to area directory.
    cd ../area
    
    # Set limits.
    if [ test -e shutdown.txt ]; 
        then rm -f shutdown.txt
    fi
    
    while [ 1 ] 
    do
        index=1000
        while [ 1 ]
        do 
    	logfile=../log/$index.log
    	if (test ! -e $logfile ) 
    	    then break
    	fi
    	index=`expr $index + 1`
        done
    
    # Run rom.
    # core dumping
        ../src/clands $port > $logfile 2>&1
    # Restart, giving old connections a chance to die.
        if (test -e shutdown.txt ) 
    	then rm -f shutdown.txt
    	mv shutdown.txt shutdown.old
        fi
    
        sleep 15
    done

    My theory:
    I think -e stands for empty unwritten to. On a successful shutdown, it writes to shutdown.txt and on an unsuccessful one it doesn't. During a reboot, we crashed thus its unwritten to and it deletes it (as it seems pointless to log an empty file. But still, it needs the next command and itís a mistake.

    Don't know how close I am but if anyone can help me, I would appreciate a swift reply.

    My thanks,

    Miet


    Well...somehow it works now...didn't do anything to it...I'm confused. I worked out that it removes the shutdown on a successful startup then rewrites it on shutdown but have no clue why it all works now.
    Last edited by Miestese; 07-06-2005 at 02:06 PM.

  2. #2
    Pursuing knowledge confuted's Avatar
    Join Date
    Jun 2002
    Posts
    1,916
    And this is C/C++ related ... how? That's a BASH script.
    Away.

  3. #3
    Registered User
    Join Date
    Jul 2005
    Posts
    2
    I never said it was C/C++ related. I said I am trying to run a C program in linux. If I would have thought the code was C/C++ related it would not be in this forum. I fixed it anyway.


    Miet

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Program Plan
    By Programmer_P in forum C++ Programming
    Replies: 0
    Last Post: 05-11-2009, 02:42 AM
  2. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 07:39 AM
  3. program to shutdown Win CE
    By Snoop67 in forum Windows Programming
    Replies: 1
    Last Post: 11-07-2002, 06:32 PM
  4. fopen();
    By GanglyLamb in forum C Programming
    Replies: 8
    Last Post: 11-03-2002, 12:39 PM
  5. startup help for my new project
    By dune911 in forum C Programming
    Replies: 6
    Last Post: 12-13-2001, 10:30 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21