|
| ||||||||||
| Tags: error message, ethernet, firewall, ip mac, kernel, linux, perl, shell script, ssh |
![]() |
| | Thread Tools | Search this Thread |
|
#1
| |||
| |||
| shell script SSH not working
Code: # / Bin / bash # / Usr / bin / expect - spawn ssh user @ IP> / Infomania / test / juniper / file.txt expect password: send "password \ r" send "get system | mac includes | Int | Ser | Software expect eof Code: Errormessage: ./ZAJOH01_IP.sh: Line 3: spawn: command not found Could not read file "password:": no such file or directory ./ZAJOH01_IP.sh: Line 5: send: command not found ./ZAJOH01_IP.sh: Line 6: send: command not found Could not read file "eof": no such file or directory Code: ssh user @ IP> / Infomania / test / juniper / file.txt Password get system | mac includes | Int | Ser | Software exit Code: Remote Management Console Device-> get system | mac includes | Int | Ser | Soft Serial Number: xxxxxxxxxxxxxx, Control Number: 00000000 Software Version: 5.xx.xrxx.x, Type: Firewall + VPN Base Mac: 0010.db44.xxxx Use interface IP, Config Port: 8005 User Name: ig-root Interface ethernet1: * Ip mac 10.182.128.14/23 0010.db44.xxxx * Manage ip 10.182.128.14, mac 0010.db44.xxxx Ethernet2 Interface: * Ip 0.0.0.0 / 0 mac 0010.db44.xxxx Ethernet3 Interface: * Ip 0.0.0.0 / 0 mac 0010.db44.xxxx Ethernet4 Interface: * Ip mac 196.30.139.43/28 0010.db44.xxxx * Manage ip 196.30.139.43, mac 0010.db44.xxxx Device-> exit ![]() |
|
#2
| ||||
| ||||
| Re: shell script SSH not working
I don't think that there should be some major mistakes. I would like to suggest you can put the full path of ssh and try spawn / usr / bin / ssh user @ IP instead of spawn ssh user @ IP. After that your code should look like : Code: # / Bin / bash # / Usr / bin / expect - spawn / usr / bin / ssh user @ IP> / Infomania / test / juniper / file.txt expect password: send "password \ r" send "get system | mac includes | Int | Ser | Software expect eof |
|
#3
| |||
| |||
| Re: shell script SSH not working
Hello, first thanks for trying to help. Now I tried and this is the error message:Code: ./MXCUA01_IP.sh: Line 3: spawn: command not found Could not read file "password:": no such file or directory ./MXCUA01_IP.sh: Line 5: send: command not found ./MXCUA01_IP.sh: Line 6: send: command not found Could not read file "eof": no such file or directory Here the input: Code: USER @ IP's password: PTY allocation request failed on channel 0 IP Connection to closed. Could not read file "password:": no such file or directory ./MXCUA01_IP.sh: Line 5: send: command not found ./MXCUA01_IP.sh: Line 6: send: command not found Could not read file "eof": no such file or directory ASRV-12: / Infomania / test / devices # ![]() |
|
#4
| ||||
| ||||
| Re: shell script SSH not working
Even I think that your are missing some basic thing so an error message is getting generated. A script also has the advantage of being run on any Unix machine without modification. It need not be compiled! The only tool needed is (usually) on all Unix machines: the shell! The steps necessary to execute the scripts:
Losing the first line in the script, because you're trying to run a script to expect inside a shell. I think this might also help you. |
|
#5
| |||
| |||
| Re: shell script SSH not working Quote:
Code: Could not read file "password:": no such file or directory ./MXCUA01_IP.sh: Line 5: send: command not found ./MXCUA01_IP.sh: Line 6: send: command not found Could not read file "eof": no such file or directory Code: # / Bin / bash / Usr / bin / ssh user @ IP> / infoman/test/juniper/MXCUA01.txt expect password: send "password \ r" send "get system | mac includes | Int | Ser | Software expect eof |
|
#6
| |||
| |||
| Re: shell script SSH not working
I have a shell script that is on three machines containing some SCO sqlplus statments. I need to run these scripts remotely. Currently, I try to use rsh to do: rsh hostname myscript args The problem is that the arguments of the statements in sqlplus remote shell scripts are ignored. If I run the script from the command line of their machines, everything works fine. So it looks like a rsh question. Here are some more detailed information: I am running rsh as follows: Code: Raptor rsh bin / YYYY my_script where the Ys are the args my_script. my_script contains the following elements: #! / Usr / bin / ksh which_sql \ u003d where `sqlplus" -S $ which_sql sti / sti <<EOF put in the off position paused off update my_table all HOST_ON_DUTY \ u003d '$ 1' EXPRESS_SHIPPING \ u003d '$ 2' INTERNATIONAL_ORDERS \ u003d '$ 3' COD \ u003d '$ 4'; output EOF bin / my_script: line 5:-s: not foundI guess the flags of the SQL statement is interpreted locally rather than remotely. Any help would be greatly appreciated!! |
|
#7
| ||||
| ||||
| Re: shell script SSH not working
I suggest you create a remote shell script. I do not use RSH more because it is not a secure connection type. I suggest you set the environment first, for example: Code: #! / Bin / sh PATH \ u003d / usr / local / sbin: / usr / sbin: / sbin: / usr / local / bin: / usr / bin: / bin |
|
#8
| |||
| |||
| Re: shell script SSH not working
It really is a multistep process. You must correctly configure SSH and create a key pair and password. Then you must load your keys in the SSH agent, so you will not be prompted for a password. The SSH agent will forward your password to other systems. Code: # Ssh-add Adding identity: / home/tester/.ssh2/id_dsa_1024_defender.pub Need passphrase for / home/tester/.ssh2/id_dsa_1024_defender.pub (1024-bit DSA test @ defender, Sun Apr 30 2000 9:39:13 p.m.). Enter passphrase: # Ssh server date Wed May 10 2:06:57 p.m. EDT 2006 # # Now that you have the SSH configuration. You can take any script and the script scp remote server. Sample script below ############################################### #! / Bin / sh LOG \ u003d "/ tmp / MYTEST.log ################## function if_error ################## ( if [[$? -Ne 0]] then # check return code passed to the function print "$ 1 TIME: $ TIME" | tee-a $ LOG # if rc> 0 then print error msg and quit exit $? fi ) chown root: root / etc / passwd if_error "Unable Chowning / etc / passwd root: root" chmod 700 / etc / passwd if_error "Unable chmoding / etc / passwd to 700 rm-rf / etc / somedir if_error "Can not delete the file / etc / somedir" ################################################ # Okay .. SSH is working and you have a little test with the control script error in it. Also, I used the tee command to redirect the script output to the screen and a log file in tmp. scp $ USER @ $ HOST: $ PATH / SCRIPT $ $ USER @ $ HOST: / tmp / $ SCRIPT ssh-l $ USER $ host chmod 700 / tmp / $ SCRIPT ssh-l $ USER $ HOST / tmp / $ SCRIPT ssh-l $ USER HOST rm / tmp / $ SCRIPT
![]() |
|
#9
| |||
| |||
| Re: shell script SSH not working
I am having some similar kind of query, so thought to post over here instead of making new thread. I would like to create a shell script to connect to a remote server via SSH (with port forwarding) and then launch an application on my local terminal. The problem is that once the connection is established the remote host, I find myself on the shell of it. Basically, after entering the password, I would stay on my local terminal to run the second command. Code: # / Bin / sh ssh-L user@XX.XXX.XXX.XX 8080:127.0.0.1:8080 open / Applications / VLC.app "mmsh: / / 127.0.0.1/8080" |
|
#10
| ||||
| ||||
| Re: shell script SSH not working
Your command opens a ssh session and not return to the script by hand to launch the following command ONLY when the ssh session is over, and then the connection will be terminated, and the tunnel closed, making the following command does not work ... So it should run your ssh in the background, waiting for the connection is established, then throw your vlc. But it's horrible, and you have no control to close the ssh properly after use. So actually, no, he must do otherwise ... Maybe like this:
Code: nc-l 9999 & & open-a VLC "mmsh: / / 127.0.0.1/8080" Code: Plotter minimize@ ~% nc-l 9999 & & echo message_recu message_recu |
![]() |
|
| Thread Tools | Search this Thread |
| |
Similar Threads for: "shell script SSH not working" | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Creating shell script in ubuntu | Elizabeth Allen | Operating Systems | 5 | 24-03-2010 01:35 PM |
| Shell script to add the extension to doc and pdf files | Tailor | Software Development | 4 | 24-02-2010 09:51 PM |
| Shell script with sed | Ameeryan | Software Development | 5 | 23-12-2009 01:29 PM |
| Shell Script Formatting | abhi701 | Software Development | 1 | 04-07-2009 04:30 PM |
| Unix Shell Script | BlackSunReyes | Software Development | 3 | 12-08-2008 01:57 PM |