I am attempting to create a shell script that will execute another shell script (mandatory by 3rd party software I'm attempting to automate).
What I want to do is simply this, once the shell script is run, it will execute the other shell script (I have that done fine and working), wait 15 seconds, and input a series of commands, with waiting time inbetween, and then exit it.
The program I am using is SteamCMD, and I am automating the server creation process. They have a scripting method included that will allow you to execute commands from a .txt file, but due to the program being new, there are bugs and I am required to wait some time between each command or else it will fail.
I attempt to do this script using spawn and expect, however that did not work. Any help will be much appreciated.
Please give us more information: Your OS and version, the shell you use and either your expect code with the error message or the code you wrote that you said worked fine and the SteamCMD so we can understand a bit, so far I understood you were trying to run an expect script on the same box (not a remote...) Is that right?
P.S.
Dont forget to put your cade and data between code tags, thanks
this is a link to the software Im attempting to automate. I tried using "spawn" and "expect" however those did not work, so I'm unsure which direction to go now.
---------- Post updated at 03:34 PM ---------- Previous update was at 03:12 PM ----------
I've tried this same variation with spawn STEAMEXE=steamcmd ./steam.sh, however it will not allow that to be spawned, so I cannot follow through with the expect script.
Actually i don't think this will run at all. The line "STEAMEXE=..." just defines a variable named "STEAMEXE" with the content of the first word behind the equal sign. Then the script waits for 60 seconds.
If this is the command you want to run do like:
STEAMEXE="steamcmd ./steam.sh +runscript csgo_ds.txt" # load the variable with the WHOLE string
$STEAMEXE # execute the variables content
sleep 60 # then wait 60 seconds
If "steamcmd" is another variable you will have to prepend "$" in front to assign "$STEAMEXE" with its content and something added. See the following example, which shows the mechanism:
a="xxx" # assign a variable
echo $a # print this variable
b="$a yyy" # create a new variable which contains the first one
echo $b # print the new variable
Furthermore: Unix is case-sensitive for the most part. Variables "A" and "a" are distinct!
#!/bin/bash
echo "CS:GO Server Install Script"
# Absolute path to this script, e.g. /home/user/bin/foo.sh
SCRIPT=`readlink -f $0`
# Absolute path this script is in, thus /home/user/bin
SCRIPTPATH=`dirname $SCRIPT`
echo $SCRIPTPATH
cd /home/csgoinstall/
STEAMEXE="steamcmd ./steam.sh"
#!/usr/bin/expect/
spawn $STEAMEXE
I'm running into an issue now of :
./jeff2.sh: line 12: spawn: command not found
Why don't you just tell us the whole story? Post your complete script here and tell us, step by step, what you want to do. It is easier to come up with a solution if we know the whole picture instead of having to debug one error after the other.