Linux - Server This forum is for the discussion of Linux Software used in a server related context. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
|
03-08-2011, 12:47 AM
|
#16
|
Member
Registered: Jun 2010
Posts: 160
Original Poster
Rep:
|
Yeah I use Swiftpanel.
And yes that would be great if you write a script for that as in that case it will do exactly what we need. So how to write a script for that ? Can you help ?
|
|
|
03-08-2011, 12:02 PM
|
#17
|
LQ 5k Club
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
|
This LQ thread may be useful regards detached screen sessions.
|
|
|
03-09-2011, 01:45 AM
|
#18
|
Member
Registered: Jun 2010
Posts: 160
Original Poster
Rep:
|
Hello.
The screen is no longer a problem now. I can run it easily like:
Code:
screen -A -m -S 10-srv207 ./Script.sh
This would open screen and run my script. But the problem is the terminal, it has to be logged in properly like we do it manually through putty for the user screen to work, otherwise the screen won't run.
I think Death's way maybe good.
|
|
|
03-09-2011, 02:41 AM
|
#19
|
LQ 5k Club
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
|
You tried screen's -d option?
|
|
|
03-09-2011, 10:28 AM
|
#20
|
Member
Registered: Nov 2007
Distribution: CentOS 6
Posts: 200
Rep:
|
Quote:
Originally Posted by AsadMoeen
Yeah I use Swiftpanel.
And yes that would be great if you write a script for that as in that case it will do exactly what we need. So how to write a script for that ? Can you help ?
|
I shut down all my gameservers a few months back. I'll have to dig around for the script. It's not exactly what your're looking for, but I'll try to comment it enough that it can be modified. At least you'll get a good idea of what the syntax is. If you have phpmyadmin installed, it's worth poking around your mysql database to see what the names of the sql fields are. You will need them.
|
|
|
03-10-2011, 01:19 AM
|
#21
|
Member
Registered: Jun 2010
Posts: 160
Original Poster
Rep:
|
Yes I have it installed. Need the scripts 
|
|
|
03-12-2011, 01:13 PM
|
#22
|
Member
Registered: Nov 2007
Distribution: CentOS 6
Posts: 200
Rep:
|
This is an example to work with. This is a code I wrote to steam update. I tried to comment it.
Code:
<?php
$id= $_GET['serverid'];
$dbname='swift';
$link = mysql_connect('localhost', $dbname, 'yoursqldbpassword');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully <br/>';
// This could be supplied by a user, for example
//Formulate Query
// This is the best way to perform an SQL query
// For more examples, see mysql_real_escape_string()
$query = sprintf("SELECT ipid, game, query, user, password, homedir FROM swift.server WHERE serverid='%s' ",
mysql_real_escape_string($id));
// Perform Query
$result = mysql_query($query);
// Check result
// This shows the actual query sent to MySQL, and the error. Useful for debugging.
if (!$result) {
$message = 'Invalid query: ' . mysql_error() . "\n";
$message .= 'Whole query: ' . $query;
die($message);
}
// Use result
// Attempting to print $result won't allow access to information in the resource
// One of the mysql result functions must be used
// See also mysql_result(), mysql_fetch_array(), mysql_fetch_row(), etc.
while ($row = mysql_fetch_assoc($result)) {
$ipid = $row['ipid'];
$game = $row['game'];
$valve = $row['query'];
$user = $row['user'];
$pass = $row['password'];
$homdir = $row['homedir'];
}
if (!($valve == 'valve')){
die( "Not a Steam game.<a href='JavaScript:window.close()'>Close</a>");
} else {
if ($game == 'Team Fortress 2'){
$game = '"tf"';
}
if ($game == 'Counter-Strike 1.6'){
$game = '"cstrike"';
}
if ($game == 'Counter-Strike: Source'){
$game = '"Counter-Strike Source"';
}
if ($game == 'Counter-Strike: Condition Zero'){
$game = '"czero"';
}
if ($game == 'Left4Dead'){
$game = '"left4dead"';
}
if ($game == 'Left4Dead2'){
$game = '"left4dead2"';
}
if ($game == 'Day of Defeat'){
$game = '"dod"';
}
if ($game == 'Day of Defeat: Source'){
$game = '"dods"';
}
if ($game == 'Garrys Mod'){
$game = '"garrysmod"';
}
if ($game == 'Half Life TV'){
$game = '"valve"';
}
// Free the resources associated with the result set
// This is done automatically at the end of the script
mysql_free_result($result);
$query2 = sprintf("SELECT ip FROM swift.ip WHERE ipid='%s' ",
mysql_real_escape_string($ipid));
$result = mysql_query($query2);
// Check result
// This shows the actual query sent to MySQL, and the error. Useful for debugging.
if (!$result) {
$message = 'Invalid query: ' . mysql_error() . "\n";
$message .= 'Whole query: ' . $query;
die($message);
}
// Use result
// Attempting to print $result won't allow access to information in the resource
// One of the mysql result functions must be used
// See also mysql_result(), mysql_fetch_array(), mysql_fetch_row(), etc.
while ($row = mysql_fetch_assoc($result)) {
$ip = $row['ip'];
}
mysql_free_result($result);
mysql_close($link);
// echo "<br/>";
// echo $ipid ;
//echo "<br/>";
// echo $game ;
//echo "<br/>";
// echo $valve ;
//echo "<br/>";
// echo $user ;
//echo "<br/>";
// echo $pass ;
//echo "<br/>";
// echo $homdir;
//echo "<br/>";
// echo $ip ;
}
if (!function_exists("ssh2_connect")) die("function ssh2_connect doesn't exist");
// log in at server1.example.com on port 22
if(!($con = ssh2_connect($ip, 22))){
echo "fail: unable to establish connection\n";
} else {
// try to authenticate with username, password
if(!ssh2_auth_password($con, $user,$pass)) {
echo "fail: unable to authenticate\n";
} else {
// allright, we're in!
echo "OK: Logged in...\n<br/><br/>";
// execute a command
$command0='./steam ';
$command1='-command update ';
$command2='-game ';
$command3=' -dir .';
$command= $command0. $command1. $command2. $game. $command3;
// echo $command ;
if (!($stream = ssh2_exec($con,$command ))) {
echo "fail: unable to execute command\n";
} else {
// collect returning data from command
stream_set_blocking($stream, true);
echo nl2br( stream_get_contents($stream));
//echo "Updating Steam...\n<br/><br/>";
//print_r($output);
// echo stream_get_line($stream,75,'...');
echo "<br/><br/>";
$data = "";
while ($buf = fread($stream,4096))
{
$data = $buf;
}
fclose($stream);
}
}
}
echo "Done...\n";
?>
<br/>
<input name="button" type="button" onclick="window.location='serversummary.php?id=<?php echo $id; ?>
'" value="Back" />
Last edited by deathsfriend99; 03-12-2011 at 01:16 PM.
|
|
|
03-13-2011, 12:57 AM
|
#23
|
Member
Registered: Jun 2010
Posts: 160
Original Poster
Rep:
|
I'll try that 
|
|
|
All times are GMT -5. The time now is 10:33 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|