I made a Linux dedicated server build in headless mode and am attempting to launch it with some commands and use this code to get them:
String[] Data = Environment.GetCommandLineArgs();
if (Data.Length == 3)
{
ip = Data[0];
port = int.Parse(Data[1]);
serverIp = Data[2];
serverPort = int.Parse(Data[3]);
Connect();
}
else
{
Application.Quit();
}
I have the .x86 file in my Linux server (hosted on digitalocean so I only have a command prompt in puTTy). I do not know how to open it however or what to even enter to get to the CommandLineArgs? Any help?
GetCommandLineArgs() will always include the path as data[0] I believe. Also, you’re accessing 4 data parts, while checking for Data.Length == 3. You’d want to check for Data.Length == 5, and starts at [1].
Ah thank you for the reply! What would the command be to launch the game on linux and also input these commands? I’m looking for something like, ‘start filepath -cmd1 -cmd2 -cmd3 -cmd4’
This still doesn’t help me. I know how to run commands detached from the command line, what I’m looking for specifically is the command to launch a .x86 headless unity build and what I would type following that to input command arguments.
Ah finally got it working.
Steps to get a Linux headless build running on digitalocean or AWS
Upload your build to a website or dropbox (needs to be an instant download link meaning when the link is opened the file automatically downloads, if you use dropbox you need to just change the end to ?dl=1, for example: https://www.dropbox.com/s/9jicrxd13nklp5o/Server.zip?dl=1)
Download the unzip ‘sudo apt-get install unzip’
Download your build ‘wget [build download link]’
Unzip the file installed ‘unzip Server.zip?dl=1’ (for some reason ?dl=1 is still kept in the file extension when using dropbox)
Give yourself permission to use the build file ‘sudo chmod +x [build].x86’
Download the following extensions using these commands
‘sudo apt-get install libc6-i386’
‘sudo apt-get install lib32stdc++6’
Finally open your linux server
'./[build].x86 -nographics -cmd0 arg0 -cmd1 arg1 -cmd2 arg 2 -cmd3 arg3…’
The code I used to get the command line arguments is this:
You should also be able to just scp your build from your desktop computer directly to your virtual machine if it is assigned a public IP address. Mac probably has scp built in, and with Windows you just get a copy of pscp.