terminal script stops after script command :(.

Hello,

i am trying to write a script for terminal for my mac that i may drag into the terminal and will excute the following command:

script -akq Desktop/TerminalLogin/Cisco1Bob.txt
telnet x.x.x.x

the problem is that when i drag the text file to the terminal window the script stops after the
script -akq Desktop/TerminalLogin/Cisco1Bob.txt
line and does not send the telnet to the screen,

any idea how to over come this problem?

Thanks,

Rasta

I am not familiar with the script command....

You typically start a shell script with a shebang, either #!/bin/bash or #!/bin/sh.

Next when you save the script, save it with the .command extension, which will make it executable from the GUI so you can just double click your script and not have to run it from terminal.

Are you trying to read something from that text file?

Hey there,

the script command logs all screen output (from the terminal) to a file, so i may review later on.

is there a different command that may do this?

this is what i got for the script (.common file):

telnet 6.20.9.35
Admin
xxxx

this is what i get when i run it in the terminal:

rastas-macbook:~ Rasta$ /Users/Rasta/Desktop/login1.common ; exit;
Trying 6.20.9.35...
Connected to cust-6.20.9.35.switchn.com.
Escape character is '^]'.

User Access Verification

Username:
Username:
Username:
Connection closed by foreign host.
/Users/Rasta/Desktop/login1.common: line 2: Admin: command not found
/Users/Rasta/Desktop/login1.common: line 3: Admin1LV082008: command not found
logout

[Process completed]

any ideas?

J.

It looks like its not authenticating. but it is hard to tell with out seeing the whole script. Can you copy/paste the whole script? You can leave out any personal information about the systems, I just want to see what commands with what switches are running.

Thanks

hey boss,

this is the hole script:

telnet 6.20.9.35
Admin
xxxx

its all in a text file that i converted to .common and made executable.

AFAIK MacOS X uses tcsh as it's default shell (or do you use something else?). If so, I have two suggestions:

  1. Use another shell. csh/tcsh are bad in terms of usability for more than executing simple commands
  2. Try changing your script as follows
    text telnet 6.20.9.35 <<EOF Admin Password EOF

I can't guarantee that that will work, as most implementations of telnet will only accept input from the terminal (keyboard that is). If the code above does not work, you should look into enabling access via SSH and a keypair. If that's not possible, try expect or netcat.

OS X 10.5 uses bash as the default shell for every user, and sh for the root user.