Sponsored Content
Top Forums Shell Programming and Scripting /usr/bin/expect script truncates data Post 302902543 by black_fender on Wednesday 21st of May 2014 04:23:32 AM
Old 05-21-2014
/usr/bin/expect script truncates data

I have a script on a Linux machine that connects remotely, via telnet on a windows machine to launch several commands and colect their output. On the Linux machine the output of these commands is redirected in a file.

The script:
Code:
#!/usr/bin/expect

log_user 0
spawn telnet 10.10.10.10
expect "login name:"
send "user1\r"
expect "password:"
send "Pa$$w0rd@\r"
expect "Windows NT Domain:"
send "\r"
#expect "C:\WINNT\Profiles\focore>"
sleep 1
send "echo prcstate\r"
send "prcstate -l\r"
sleep 1
send "echo hwmls\r"
send "hwmls\r"
sleep 1
send "echo hwmscbls\r"
send "hwmscbls\r"
sleep 1
send "echo cluster res\r"
send "cluster res\r"
sleep 1
send "echo cluster node\r"
send "cluster node\r"
sleep 1
send "echo cluster group\r"
send "cluster group\r"
sleep 1
send "echo cluster netint\r"
send "cluster netint\r"
sleep 1
send "echo mtzln -p\r"
send "mtzln -p\r"
sleep 1
send "echo time /t\r"
send "time /t\r"
sleep 1
send "echo date /t\r"
send "date /t\r"


send "exit\r"
interact
exit

When I launch the script "manually" from the shell
Code:
 ./expect.sh > output.txt

The entire output is capted.
When I schedule the script in crontab no output is capted (probably due to the "interact" part of the script).
When I use a wrapper script which launches expect.sh and schedule the wrapper script in crontab output.txt contains only exactly 4.0 Kb and truncates the output of the commands in expect.sh
Code:
 cat wrapper.sh
#!/bin/bash

target_log=/absolute_path/output.txt

rm -f $target_log

/absolute_path/expect.sh >> $target_log

I'm new to expect and I don;t know how to overcome this. I've red about a full_buffer command but didn;t succeed to get the right syntax to implement it in my script.
Any ideas how to overcome this ?
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

/bin/sh: /usr/bin/vi: No such file or directory when doing crontab

I just set up an ftp server with Red Hat 5.2. I am doing the work, I'm baby stepping, but it seems like every step I get stuck. Currently, I'm trying to set up a crontab job, but I'm getting the following message: /bin/sh: /usr/bin/vi: No such file or directory. I see that vi exists in /bin/vi,... (3 Replies)
Discussion started by: kwalter
3 Replies

2. Shell Programming and Scripting

#!/usr/bin/ksh Command Interpreter in a sh script

Hi, I have a developer that is trying to start a script with sh "scriptname". In the script, he is specifying #!/usr/bin/ksh as the command interpreter. For some reason sh is ignoring the #!/usr/bin/ksh. We are running Solaris 8. Does anyone have any ideas what could be causing this? Here... (3 Replies)
Discussion started by: ckeith79
3 Replies

3. Shell Programming and Scripting

Script can't see /usr/bin???

Hello all, I have the following script (still in early stages), and although I can't help but think that the problem is very simple, I can't think of a solution. My script can't see binaries in /usr/bin. This isn't a problem with my login shell as I can execute these commands OK there. I've... (1 Reply)
Discussion started by: michaeltravisuk
1 Replies

4. Solaris

How do I link ld in /usr/ucb/ to /usr/ccs/bin?

Hi all, below is the problem details: ora10g@CNORACLE1>which ld /usr/ucb/ld ora10g@CNORACLE1>cd /usr/ccs/bin ora10g@CNORACLE1>ln -s /usr/ucb/ld ld ln: cannot create ld: File exists ora10g@CNORACLE1> how to link it to /usr/ccs/bin? (6 Replies)
Discussion started by: SmartAntz
6 Replies

5. UNIX for Dummies Questions & Answers

Alias /usr/bin to /bin in profile

Hi! All the basic linux commands, ie. echo, find, etc, are located in /bin. I have a couple of programs that have these commands pointed towards /usr/bin, ie, /usr/bin/echo (even though the actual 'echo' command is in /bin). How can I alias or redirect or link the /usr/bin to /bin just for this... (6 Replies)
Discussion started by: dancerat
6 Replies

6. OS X (Apple)

When to use /Users/m/bin instead of /usr/local/bin (& whats the diff?)?

Q1. I understand that /usr/local/bin means I can install/uninstall stuff in here and have any chance of messing up my original system files or effecting any other users. I created this directory myself. But what about the directory I didn't create, namely /Users/m/bin? How is that directory... (1 Reply)
Discussion started by: michellepace
1 Replies

7. Solaris

What is the difference between xpg4/bin and usr/bin?

Hi Experts, I found that the same commands(sort, du, df, find, grep etc.) exists in both dir. What is the difference to use them? i.e: to use xpg4/bin/grep and usr/bin/grep My OS version is SunOS 5.10 Regards, Saps (7 Replies)
Discussion started by: saps19
7 Replies

8. Shell Programming and Scripting

AIX -/usr/bin/expect shows output Don't know why.

Hi, I have been programming with the expect program for a while now and have create a series of menu driven checks for the operations team. One thing I have noticed is that I call a remote script and pass parameters and this is display on the screen....for example. Within the script ... (0 Replies)
Discussion started by: yakky
0 Replies

9. BSD

FreeBSD: /usr/bin/ld not looking in /usr/local/lib

I'm not sure if this is the default behavior for the ld command, but it does not seem to be looking in /usr/local/lib for shared libraries. I was trying to compile the latest version of Kanatest from svn. The autorgen.sh script seems to exit without too much trouble: $ ./autogen.sh checking... (2 Replies)
Discussion started by: AntumDeluge
2 Replies
INITSCRIPT(5)						Linux System Administrator's Manual					     INITSCRIPT(5)

NAME
initscript - script that executes inittab commands. SYNOPSIS
/bin/sh /etc/initscript id runlevels action process DESCRIPTION
When the shell script /etc/initscript is present, init will use it to execute the commands from inittab. This script can be used to set things like ulimit and umask default values for every process. EXAMPLES
This is a sample initscript, which might be installed on your system as /etc/initscript.sample. # # initscript Executed by init(8) for every program it # wants to spawn like this: # # /bin/sh /etc/initscript <id> <level> <action> <process> # # Set umask to safe level, and enable core dumps. umask 022 ulimit -c 2097151 PATH=/bin:/sbin:/usr/bin:/usr/sbin export PATH # Increase the hard filedescriptor limit for all processes # to 8192. The soft limit is still 1024, but any unpriviliged # process can increase it's soft limit up to the hardlimit # with "ulimit -Sn xxx" (needs a 2.2.13 or later Linux kernel). ulimit -Hn 8192 # Execute the program. eval exec "$4" FILES
/etc/inittab, /etc/initscript. AUTHOR
Miquel van Smoorenburg ,<miquels@cistron.nl> SEE ALSO
init(8), inittab(5). December 24, 1999 INITSCRIPT(5)
All times are GMT -4. The time now is 10:10 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy