Just kinda offtopicish, whats the best way to make a loop script in ubuntu? Im making a script that checks what time it is and shutsdown the server if its a certain time and i need it to loop to the if time =... Posted via Mobile Device
Same for any computer language
while (true) {}, syntax may vary
From what you said though you are better off using cron as that is what it is there for...
14-07-11
NaMeLeS
Re: Auto Announcement sPWAdmin [need help]
Thanks das, I have written the script/s which displays server shutdown notices and then shuts down the server.
I shall try cron for getting it to run at a certain time.
Thanks :)
14-07-11
jh281978
Re: Auto Announcement sPWAdmin [need help]
I am still having issues with this, I guess I am still to much of nob with php, more trial and error to come. Thanks guys.
17-07-11
Suedevander
Re: Auto Announcement sPWAdmin [need help]
not understood explains again
27-07-11
jh281978
Re: Auto Announcement sPWAdmin [need help]
Ok here is the deal ( I am about ready to pull out all my hair and teeth lol which would make me a very ugly woman )
This is my crontab:
Code:
# /etc/crontab: system-wide crontab
# Unlike any other crontab you don't have to run the `crontab'
# command to install the new version when you edit this file
# and files in /etc/cron.d. These files also have username fields,
# that none of the other crontabs do.
And I am running my test server on Debian 6.0, with ronny1982's server setup with MySQL.
I can't get the auto announcements to run at all. I'm dieing here any suggestions, Please. Thanks guys.:blink::*:
27-07-11
das7002
Re: Auto Announcement sPWAdmin [need help]
Quote:
Originally Posted by jh281978
Ok here is the deal ( I am about ready to pull out all my hair and teeth lol which would make me a very ugly woman )
This is my crontab:
Code:
# /etc/crontab: system-wide crontab
# Unlike any other crontab you don't have to run the `crontab'
# command to install the new version when you edit this file
# and files in /etc/cron.d. These files also have username fields,
# that none of the other crontabs do.
And I am running my test server on Debian 6.0, with ronny1982's server setup with MySQL.
I can't get the auto announcements to run at all. I'm dieing here any suggestions, Please. Thanks guys.:blink::*:
*points back to my method with PHP yet again*
27-07-11
jh281978
Re: Auto Announcement sPWAdmin [need help]
das7002 can you explain were the code goes cause I have no idea were to place it or how to use it, ( nob still ) step by step if possible so I can learn some more. Thanks.
28-07-11
das7002
Re: Auto Announcement sPWAdmin [need help]
Quote:
Originally Posted by jh281978
das7002 can you explain were the code goes cause I have no idea were to place it or how to use it, ( nob still ) step by step if possible so I can learn some more. Thanks.
Anywhere you want, it doesn't matter. Lets say you put it into /autoannounce/announce.php
Then in your cron you'd simply use
Code:
php /autoannounce/announce.php "Message to broadcast"
---------- Post added at 07:45 PM ---------- Previous post was at 07:37 PM ----------
Quote:
Originally Posted by das7002
I'd actually recommend just using php5-cli over that
This doesn't rely on the JSP server running and you can run it from any server that has PHP-CLI support
Quote:
No more silly shell scripts and JSP stuff
You can think it's silly all you want, but at least JSP is something people are going to already have AND be using anyway (pwAdmin). No real reason to install PHP-CLI just for "announcements"...
Spoiler:
+plus+ have fun when people start complaining about it not working since they don't have PHP-CLI installed, and people asking you to help with the installation of it =\
30-07-11
jh281978
Re: Auto Announcement sPWAdmin [need help]
Again no luck, but I did find an article about problems running crons if they are writing to a file in my home folder cause its encrypted, so it wouldn't work unless I was logged in to my test sever pc, this might be an issue for this as well. I'm still getting this error from my system log.
Code:
(CRON) error (grandchild #2769 failed with exit status 127)
I'll find it soon more trial and error.
30-07-11
hrace009
Re: Auto Announcement sPWAdmin [need help]
Quote:
Originally Posted by jh281978
Again no luck, but I did find an article about problems running crons if they are writing to a file in my home folder cause its encrypted, so it wouldn't work unless I was logged in to my test sever pc, this might be an issue for this as well. I'm still getting this error from my system log.
Code:
(CRON) error (grandchild #2769 failed with exit status 127)
function mShort($p) { return mBytes($p,8); }
function mInt($p) { return mBytes($p,24); }
function mLong($p) { return mBytes($p,56); }
function mUInt32($p) {
if ($p < 64)
return mByte($p);
if ($p < 16384)
return mShort($p | 0x8000);
if ($p < 536870912)
return mInt($p | 0xC0000000);
return mInt(-32) . mInt($p);
}
function mSInt32($p) {
if ($p >= 0)
return mUInt32($p);
$t=-$p;
if ($t < 64)
return mByte($p | 0x40);
if ($t < 16384)
return mShort($p | 0xA000);
if ($t < 536870912)
return mInt($p | 0xD0000000);
return mInt(-16). mInt($p);
}
function mOctets($p) {
$packed = mUInt32(count($p));
for ($i = 0; $i < count($p); $i++)
$packed .= mByte($p[$i]);
return $packed;
}
broadcast($argv[1]);
?>
and use
php whateveryoucalledit.php "Message to broadcast"
This doesn't rely on the JSP server running and you can run it from any server that has PHP-CLI support
Great :w00t:
30-07-11
343
Re: Auto Announcement sPWAdmin [need help]
Quote:
Originally Posted by jh281978
Again no luck, but I did find an article about problems running crons if they are writing to a file in my home folder cause its encrypted, so it wouldn't work unless I was logged in to my test sever pc, this might be an issue for this as well. I'm still getting this error from my system log.
Code:
(CRON) error (grandchild #2769 failed with exit status 127)
I'll find it soon more trial and error.
You NEED to be more concerned with NETWORK security (opposed to LOCAL security) [you're not dealing with an ATM here...]
;)
30-07-11
das7002
Re: Auto Announcement sPWAdmin [need help]
Quote:
Originally Posted by 343
You can think it's silly all you want, but at least JSP is something people are going to already have AND be using anyway (pwAdmin). No real reason to install PHP-CLI just for "announcements"...
Well they probably already have php5-cgi or apache2-mod-php5 so adding php5-cli isn't that much to ask...
Quote:
Originally Posted by 343
You NEED to be more concerned with NETWORK security (opposed to LOCAL security) [you're not dealing with an ATM here...]
;)
I found that somewhat funny too... if someone has access to the machine it doesn't matter how much security you have they can get in...
30-07-11
jh281978
Re: Auto Announcement sPWAdmin [need help]
New error code after changing the .sh's
Code:
(CRON) error (grandchild #3651 failed with exit status 126)
I found this
Code:
126 | Command invoked cannot execute | Permission problem or command is not an executable
function mShort($p) { return mBytes($p,8); } function mInt($p) { return mBytes($p,24); } function mLong($p) { return mBytes($p,56); }
function mUInt32($p) { if ($p < 64) return mByte($p); if ($p < 16384) return mShort($p | 0x8000); if ($p < 536870912) return mInt($p | 0xC0000000); return mInt(-32) . mInt($p); } function mSInt32($p) { if ($p >= 0) return mUInt32($p); $t=-$p; if ($t < 64) return mByte($p | 0x40); if ($t < 16384) return mShort($p | 0xA000); if ($t < 536870912) return mInt($p | 0xD0000000); return mInt(-16). mInt($p); }
function mOctets($p) { $packed = mUInt32(count($p)); for ($i = 0; $i < count($p); $i++) $packed .= mByte($p[$i]); return $packed; }
broadcast($argv[1]);
?>
and use
php whateveryoucalledit.php "Message to broadcast"
This doesn't rely on the JSP server running and you can run it from any server that has PHP-CLI support
Code:
PHP Parse error: syntax error, unexpected T_DNUMBER in /root/broadcast.php on line 7
Can you fix that Das?
10-08-11
das7002
Re: Auto Announcement sPWAdmin [need help]
Quote:
Originally Posted by Romulan
Code:
PHP Parse error: syntax error, unexpected T_DNUMBER in /root/broadcast.php on line 7
Can you fix that Das?
I always disliked how PHP did line numbers for errors (sometimes you get the actual line other times you get the line after it and that causes all kinds of hell with debugging)
Turns out I forgot that PHP (sometimes) dislikes IP addresses just sitting in plain text (as I just did a quick CLI conversion based on what I had already used in PW-Chat)