Spawn command not found!!!


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Spawn command not found!!!
# 1  
Old 01-14-2015
RedHat Spawn command not found!!!

Hi,
I am writing a script to automate installation of java in shell script.
Code:
#!/bin/sh
#!/usr/bin/expect
ls -la | grep jdk* | rpm -ivh ./jdk*.rpm
alternatives --install /usr/bin/java java /usr/java/jdk1.7.0_71/bin/java 2
spawn alternatives --config java
expect "Enter to keep the current selection[+], or type selection number: "
send "2\r"

I am getting the following error while executing this script
Code:
[root@localhost ]# ./javaUpdate.sh
Preparing...                ########################################### [100%]
        package jdk-2000:1.7.0_71-fcs.i586 is already installed
./javaUpdate.sh: line 5: spawn: command not found
couldn't read file "Enter to keep the current selection[+], or type selection number: ": no such file or directory
./javaUpdate.sh: line 7: send: command not found

Spawn is working to other ssh script at the same server.
Can anyone let me why these errors are ?

Thanks Smilie

Last edited by Franklin52; 01-14-2015 at 09:58 AM.. Reason: Please use code tags
# 2  
Old 01-14-2015
Please use code tags as required by forum rules!

spawn is NOT a shell command but an expect (which you don't run) builtin.
I don't think it "is working to other ssh script at the same server" unless you run expect in there.
This User Gave Thanks to RudiC For This Post:
# 3  
Old 01-14-2015
Thanks for reply. it has another errors after changing it to expect as:
Code:
[root@ldapclient rncit]# cat javaUpdate.sh
#!/usr/bin/expect -f
ls -la | grep jdk* | rpm -ivh ./jdk*.rpm
alternatives --install /usr/bin/java java /usr/java/jdk1.7.0_71/bin/java 2
spawn alternatives --config java
expect "Enter to keep the current selection[+], or type selection number: "
send "2\r"

Errors

Code:
 invalid command name "ls"
    while executing
"ls -la | grep jdk* | rpm -ivh ./jdk*.rpm"
    (file "./javaUpdate.sh" line 2)

# 4  
Old 01-14-2015
ls is a system command, as are grep and rpm. You can't mix up expect internals with system and shell commands.
Please make sure you understand the difference between shell and expect application.
# 5  
Old 01-14-2015
Have you tried:
Code:
$ yum search jdk
# yum install java-1.8.0-openjdk

Hope this helps

NOTE: Ok i'm on fedora and might have a newer package, but otherwise its the same on any RedHat based system.
# 6  
Old 01-16-2015
It ok! in case of new installation not in java-upgrade when you have no epel connected to internet. java is already installed to java-1.6.0 but need to upgrade this by rpm.
can you LEt me how to give input to this command automatically agianst to pattern matching /usr/java/jdk1.7.0_71/bin/java?

Code:
[root@localhost ~]# alternatives --config java

There are 3 programs which provide 'java'.

  Selection    Command
-----------------------------------------------
*  1           /usr/lib/jvm/jre-1.6.0-openjdk/bin/java
   2           /usr/lib/jvm/jre-1.5.0-gcj/bin/java
 + 3           /usr/java/jdk1.7.0_71/bin/java

Enter to keep the current selection[+], or type selection number:

Is this possible with shell ?
Thanks

Last edited by Don Cragun; 01-16-2015 at 05:19 AM.. Reason: Add CODE and ICODE tags.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Spawn fatal do not run this command by hand

spawn ssh oracle@$myserver $mycommand match_max 100000 expect "*?assword:*" send "$v_password\r" send "\r" expect eof I run this code above and got the error. spawn: fatal: do not run this command by hand Thanks (3 Replies)
Discussion started by: zam
3 Replies

2. Red Hat

Spawn: command not found

Dear Concern, I want to run following script in RHEL 6.3. $ cat sftp_upload.sh #!/usr/bin/expect spawn sftp -oPort=434 bkashtopup@172.16.252.59 expect "*?assword:*" send "bkashtopup1234\n" send "lcd /BI/application/report/script/daily/daily_bkash_itopup_detail\r" expect sftp> ... (3 Replies)
Discussion started by: makauser
3 Replies

3. Red Hat

Spawn: Command not found

Hi all, I want to run the following command from my main prompt : # spawn bash but I get the following error: spawn: Command not found. For this to work , I first have to go into expect. #expect expect1.1>spawn bash spawn bash 564 expect1.2> Is there any way I can skip the... (2 Replies)
Discussion started by: Junaid Subhani
2 Replies

4. Shell Programming and Scripting

Using expect command, spawn will not start sftp process

Hi all, I have a script that runs sftp with expect so I can login and send a file in a cronjob. I've installed this on a couple other servers and it has been fine. However, this time on this machine, it seems to be giving me an issue. It won't move past the spawn sftp command and return a... (3 Replies)
Discussion started by: ltyrrell
3 Replies

5. Shell Programming and Scripting

When i am trying to execute export command within a shell script it is saying command not found.

I am running the export command within a view to use that value inside my build script. But while executing it it is saying "export command not found" My code is as follows: -------------------------- #!/bin/sh user="test" DIR="/bldtmp/"$user VIEW="test.view1" echo "TMPDIR before export... (4 Replies)
Discussion started by: dchoudhury
4 Replies

6. Shell Programming and Scripting

Can 'spawn' command be used more than once in an expect script ?

Can 'spawn' script be used more than once in a given expect script ?? What I'm trying to do is, first log-into a remote server through one 'ssh' spawn com and then from there log-into another server using a secod 'ssh' spawn command. But this approach is not working... the second ssh attempt... (1 Reply)
Discussion started by: clakkad
1 Replies

7. UNIX for Advanced & Expert Users

Spawn a new unix window by command

Hi Experts, I hav a question for you.. Can we open a new window(SunOS 5.10,Putty) by a unix_command from the one we're on? Is it possible? Thanks. (2 Replies)
Discussion started by: Hunter85
2 Replies

8. Solaris

Spawn Not Found

I need to run the spawn command but when I typed it in, I got "ksh: spawn: not found". So, I downloaded spawn-fcgi but it required to be compiled first. The compile failed when I tried it. I need a copy that's ready to be used. Unix system info: OS: Sun Solaris 2.8 Shell: ksh Does... (4 Replies)
Discussion started by: april
4 Replies

9. UNIX for Dummies Questions & Answers

spawn: not found

Hi, I'm very new to UNIX. I need to FTP a file to a remote host. It happens through a port 2222.I need to automate the process as the SCP command prompts for a password. 1) The regular ftp, tells me that the connection is refused 2) The sftp login@remotehost gives me... (0 Replies)
Discussion started by: sandy.cog
0 Replies

10. Shell Programming and Scripting

how can i check in csh if command found or not found ?

hello all im trying to use in sun Solaris the information received from the top command now i several machines that dont have install the top program so when im running the script im geting error saying after im running this code : set MemoryInfo = `top | grep Memory` if (... (2 Replies)
Discussion started by: umen
2 Replies
Login or Register to Ask a Question