terminal script stops after script command :(.


 
Thread Tools Search this Thread
Operating Systems OS X (Apple) terminal script stops after script command :(.
# 1  
Old 01-20-2009
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
# 2  
Old 01-20-2009
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?
# 3  
Old 01-21-2009
not sure there.

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.
# 4  
Old 01-21-2009
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
# 5  
Old 01-21-2009
here we go.

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.
# 6  
Old 01-21-2009
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
    Code:
    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.
# 7  
Old 02-04-2009
OS X 10.5 uses bash as the default shell for every user, and sh for the root user.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Execute ssh command with additional terminal command to any remote user not working script

Hello i am having an issue with bash script and this is the code now=$(cat hosts1.txt | awk '{print $2;}') while read n ;do ssh root@$now 'useradd test1; echo -e "test1\ntest1" | passwd test1 && echo "test1 ALL=(ALL:ALL) ALL" >> /etc/sudoers' When i execute only part with cat, it... (8 Replies)
Discussion started by: tomislav91
8 Replies

2. Shell Programming and Scripting

Copy Script Stops

Good Morning, I have a copy script on Solaris 9 machine that is supposed to copy some files to a NAS using: cp -r /dir/dir/ /dir/dir/dirThe script doesn't finish. The directory contains user files of which one seems to copy fine, a second was failing until I did achmod -R -777 to it. Now,... (6 Replies)
Discussion started by: Stellaman1977
6 Replies

3. Shell Programming and Scripting

perl: Command works in terminal, but not in shell script

Hi, the following command works in the terminal no problem. samtools view -h rawlib.bam | perl -ne '{ @line = split( /\s+/ ); $match = 0; while( $line =~ /(\d+)M/g ) { $match = $match + $1 } if( $match >= 80 || $_ =~ /^\@/ ) { print $_ } }' | java -Xmx12G -jar... (8 Replies)
Discussion started by: jdilts
8 Replies

4. Shell Programming and Scripting

My script stops after logoff...why??

Hi' i am runing a script thats run with a loop...while loop true. when i exit the server..logon and again the script doenst run. its a bash script test.sh. i run it as: #./test.sh & what can be the priblem please? thanks alot (6 Replies)
Discussion started by: zigizag
6 Replies

5. Shell Programming and Scripting

My script stops working when using crontab

I have made a shell script(/bin/sh) that starts a perl script (that I haven't made my self) that's starts a ssh session. The ssh session uses a private/public key to login so no password is needed. The Perl script works perfect. But when I put it in a cronjob (crontab) the ssh connection asks... (6 Replies)
Discussion started by: splinter_cell
6 Replies

6. Shell Programming and Scripting

Script stops working after copying it

Hi all, When I cp a script, this section of the code stops reading from a file. if ; then while read dirtoclean do DIRSTOCLEAN=${DIRSTOCLEAN}' '$dirtoclean done < ${BASEDIR}test.conf fi ${DIRSTOCLEAN} doesn't return anything, even though it will work right before... (6 Replies)
Discussion started by: nicksantos1
6 Replies

7. OS X (Apple)

Terminal Command into script

Hi All I have this script that checks to see if ntp is enabled on a machine launchctl load -w /System/Library/LaunchDaemons/org.ntp.ntpd.plist It retuns org.ntp.ntpd: Already loaded if it is loaded, is there a way to script it so that if it is loaded it does not say anything but... (2 Replies)
Discussion started by: ab52
2 Replies

8. UNIX for Dummies Questions & Answers

Script to run a command in a new terminal

Hey, I am trying to write a script that will open all of my session windows, and then secure shell into the appropriate server in the new windows. Seems simple, but I cant get it to work! Please help! :confused: (1 Reply)
Discussion started by: sojo1024
1 Replies

9. Shell Programming and Scripting

Why My Script Stops After 1st Command

My script is very simple. It call isql and then echo a message. The problem is after the 1st command (isql), it stops so that the echo line never gets executed. Can anyone let me know what is wrong? #!/usr/bin/sh userid=xxxx server=xxxx db=xxxx pwd=xxxx isql -U ${userid} -S ${server}... (3 Replies)
Discussion started by: robbyls
3 Replies

10. Shell Programming and Scripting

how to start SCRIPT command at begin of TERMINAL?

Hello sir, I want to monitor my work on the terminal.I know we can use script command.But every time when I start the terminal, I have to type script to start it.I want to automate it. So where should I include this command so that it will start as soon as I start the terminal ???? (2 Replies)
Discussion started by: nsharath
2 Replies
Login or Register to Ask a Question