User Input Automation without Spawn


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting User Input Automation without Spawn
# 8  
Old 05-15-2012
Quote:
Code:
#!/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
You have an extra forward slash in your shebang after expect (highlighted in RED above)...

Last edited by Finja; 05-15-2012 at 10:14 PM..
# 9  
Old 05-16-2012
Quote:
Originally Posted by foghsho
I'm running into an issue now of :
./jeff2.sh: line 12: spawn: command not found
The reason is that line 11 is ignored and the shell (bash) doesn't know the "spawn"-command. This:

Code:
#!/path/to/some/shell

can only be used once to explicitly load some shell at the beginning of a script, so this line is valid only if it is the first line, otherwise not.

If you want to change the shell in between you have to call an external script, which can have its own first line. Like this:

Code:
#!/bin/bash

some_command

/path/to/script.ext

some_other_command

this is the content of /path/to/script.ext:
Code:
#!/bin/expect

spawn .....

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.

I hope this helps.

bakunin
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

User input and run awk using the input

I am trying to allow a user to enter in text and then store that text in a variable $gene to run in an awk command in which those values are used to run some calculations. I am getting syntax errors however, when I try. Thank you :). The awk runs great if it is a pre-defined file that is used,... (7 Replies)
Discussion started by: cmccabe
7 Replies

2. Shell Programming and Scripting

Hide the output of spawn ssh user@server

Hi All, I have written one script, which is connecting 3 diffrent servers and executing script placed on those. It is smthing like: spawn ssh user@server1 expect "*? assword:" send "pw \r" expect "$" send " sh ./filename1 \r" expect "$" expect eof spawn ssh user@server2 expect "*?... (7 Replies)
Discussion started by: KDMishra
7 Replies

3. Shell Programming and Scripting

Script interacts with user , based on user input it operates

i have a script which takes input from user, if user gives either Y/y then it should continue, else it should quit by displaying user cancelled. #!/bin/sh echo " Enter your choice to continue y/Y OR n/N to quit " read A if then echo " user requested to continue " ##some commands... (7 Replies)
Discussion started by: only4satish
7 Replies

4. Shell Programming and Scripting

How to get the user input recursively until the user provides valid input

Hi, echo "Enter file name of input file list along with absolute path : " read inputFileList if then for string in `cat inputFileList` do echo $string done else echo " file does not exist" fi From the above code, if the user enters a invalid file... (1 Reply)
Discussion started by: i.srini89
1 Replies

5. Shell Programming and Scripting

user input in perl?

Please tell me how to write a perl script that asks the user to enter words and that passes them to a variable. In bash, the "read" command would achieve such user interaction. #!/bin/bash read -p "Enter files: " vFiles However, I am looking for perl version of something equivalent... (2 Replies)
Discussion started by: LessNux
2 Replies

6. Programming

spawn a process with a different user

Hello Everyone: I have the following code int main() { system("/usr/OtherUser/bin/runX"); return 0; } runX must be executed with privileges from another user, how could I do that? I know the password for such user. Thanks in advance (8 Replies)
Discussion started by: edgarvm
8 Replies

7. Shell Programming and Scripting

Bash user input

Hi all, I currently have a script which uses read -p for user interaction. e.g. read -p "New user? " user Is it possible to have it so if the user enters nothing and just presses return it can resort to a specified value instead? Thanks! :) (5 Replies)
Discussion started by: JayC89
5 Replies

8. Shell Programming and Scripting

Need help with user password automation

Hello, I need some assistance in trying to figure out the best way to automate user account password resets. The environment is a mix of 2000 HP-ux, aix, linux, and sunos boxes. The security specs are to reset pw's every 90 days. Most boxes are only accessible from within a current ssh... (2 Replies)
Discussion started by: deviousdoses
2 Replies

9. Shell Programming and Scripting

Reading input from user

how do we read input from a user e.g i want to ask a user to enter 6 sets of numbers how do i control information from the user? i have this....... #!/bin/bash echo "Please enter six numbers" read number echo $number >> file1 but this stops after the first number..how can i... (2 Replies)
Discussion started by: vadharah
2 Replies

10. Shell Programming and Scripting

Getting user input

I am trying to create a shell (ksh) which has two "read" commands, one which reads a line from a file and another which is inside a loop that reads user input from a keyboard. However, the "read" command inside the loop uses the input from the file and it does not get the user input from keyboard.... (3 Replies)
Discussion started by: stevefox
3 Replies
Login or Register to Ask a Question