script not displaying output correctly


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting script not displaying output correctly
# 1  
Old 07-10-2009
script not displaying output correctly

Hi,

I am having an issue with my script, ofcourse...
I am trying to run commands against a remote server, I am pulling the hostnames or IPs from a file list, then looping thru and running the date cmd. I will be running different cmds just trying to get it working first.
The ouput isn't showing up in my output file or on the screen correctly.
It give me = "ksh: Fri: not found" instead of Fri Jul 10 11:30:11 EDT 2009 , if I can't get this simple cmd to work, how am I going to print, hostname, uname -a, prtconf etc.....

All the echos are me troubleshooting, and the sleep is me trying to see if it was disconnecting before it was complete.

Any help is mucho thankso!

My Script =
##########################################
Code:
#!/bin/ksh
MesFile=/tfess/errfile.log
Out=/tfess/output.txt
Date=`date`
Ping=`ping -c 1 "$ips"`
# Ssh=`/usr/bin/ssh`
Space=" | "
Server=`hostname`
Hosts=`cat /tfess/hostlist.txt|wc -l`
count=1
while [ $Hosts -ge $count ]
 do
  lpar=`sed -n "$count"p hostlist.txt|cut -f 1 -d ","`
  ips=`sed -n "$count"p hostlist.txt|cut -f 2 -d ","`
    echo "$ips"
    echo "$count"
    echo "$?"
    echo "$ips"
    Ting="$Ping"
    echo "$?"
  if [ `echo $?` -ne "1" ];then
    /usr/bin/ssh "$lpar" "$Date" 1>>$Out 0>&1
 sleep 3
   else
    echo "$lpar not able to connect via ssh" 1>$mesFile 0>&1
  fi
count=`expr $count + 1`
done

##########################################


My ouput =

######################################
Code:
myserver:/tfess>sh test.sh
10.x.x.x
1
0
10.x.x.x
You have accessed a system intended for the exclusive
use of authorized company employees and contractors
for the purpose of performing necessary job related
duties and transactions.  Unauthorized access is
prohibited and is subject to prosecution to the full
extent of the law.  Employee use of company systems or
software for other than that stated purpose may result
in disciplinary action, up to and including discharge.
This company reserves the right to monitor company
systems to determine compliance with this policy, or
as otherwise approved by Corporate Information Security,
General Counsel or Vice President of Auditing.
ksh: Fri:  not found.

###################################

Last edited by vgersh99; 07-10-2009 at 12:49 PM.. Reason: code tags, PLEASE!
# 2  
Old 07-10-2009
To keep the forums high quality for all users, please take the time to format your posts correctly.

First of all, use Code Tags when you post any code or data samples so others can easily read your code. You can easily do this by highlighting your code and then clicking on the # in the editing menu. (You can also type code tags [code] and [/code] by hand.)

Second, avoid adding color or different fonts and font size to your posts. Selective use of color to highlight a single word or phrase can be useful at times, but using color, in general, makes the forums harder to read, especially bright colors like red.

Third, be careful when you cut-and-paste, edit any odd characters and make sure all links are working property.

Thank You.

The UNIX and Linux Forums
# 3  
Old 07-10-2009
What is the meaning of this string???
Code:
/usr/bin/ssh "$lpar" "$Date" 1>>$Out 0>&1

Maybe you shold try
Code:
/usr/bin/ssh "$lpar" date 1>>$Out 0>&1

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Python Output Displaying Horizontal

I feel bad for posting so much lately. I've just been working on a project for fun to force myself to learn Python better. Recently I decided to incorporate this ping.py script on github found here. I'm not going to bore you with all the changes I made, but the problem now lies in this function... (8 Replies)
Discussion started by: Azrael
8 Replies

2. Shell Programming and Scripting

Displaying log file pattern output in tabular form output

Hi All, I have result log file which looks like this (below): from the content need to consolidate the result and put it in tabular form 1). Intercomponents Checking Passed: All Server are passed. ====================================================================== 2). OS version Checking... (9 Replies)
Discussion started by: Optimus81
9 Replies

3. Shell Programming and Scripting

Date not displaying correctly

Hi Experts, I tried to stay away from posting stuff here and asking for help. I want to print date valeu for a given variable and that is not working. #!/bin/bash START=`echo $1 | tr -d _`; FV=`echo $2` for (( c = 0 ; c < $FV ; c++ )) do # echo -n "`date --date="$START +$c day"... (12 Replies)
Discussion started by: PG3
12 Replies

4. Shell Programming and Scripting

KSH Output not coming correctly !!!

Guys, I need some help, the output for my script below is causing me some issues.... Not sure where i am going wrong.. The out put should be all one line, but from some reasons its coming out on 4 lines... Can you suggesst what i am doing wrong please!!!!!! for MEDIA in `cat... (6 Replies)
Discussion started by: Junes
6 Replies

5. Shell Programming and Scripting

Displaying the output in the tabular Format

Hi, I have a file which contains the data in the below format and need to develop a script which will give the output in the tabular format. Could you please advice me. Folder: Workflow: version . Workflow run status: Workflow run error code: Schedule time: Workflow run type: ... (2 Replies)
Discussion started by: kandi.reddy
2 Replies

6. Shell Programming and Scripting

Output Parameter value not displaying

Hi all, Below is my shell script that calls a stored procedure(with output parameter) I have tried executing this script but it doesn't display the output parameter value. Can anyone help me ? :( #!/bin/bash ###############################################################################... (7 Replies)
Discussion started by: saviochacko
7 Replies

7. Shell Programming and Scripting

Displaying Output in Columns

I'm writing a script to analyze the logs of an smtp relay machine and I'd like the final output to be displayed in columns showing results from the previous day, week, month, and 45 days. The problem I'm running into is that I can't figure out how to display the columns neatly so there is no... (1 Reply)
Discussion started by: jjamd64
1 Replies

8. Shell Programming and Scripting

Displaying output from df -k in GB instead of KB

Hello all, Code below: echo "Oracle Filesystems" echo "------------------" echo for j in `df -l -k |grep total|grep ora|grep -v storage|grep -v vg00|awk '{print $1}'` do echo $j is `df -l -k $j |grep total|grep ora|grep -v storage|grep -v vg00|awk -F":" '{print $2}'|awk '{print $1}'` KB... (6 Replies)
Discussion started by: LinuxRacr
6 Replies

9. Shell Programming and Scripting

displaying output in a table.

Hello, I've just finished my first script (about displaying open ports on the computer and who opened them) and everything is fine with it but I want to style it a little bit just for the sake of learning how to do this. What I want to do is make the display like the one of ps, for example,... (6 Replies)
Discussion started by: sanchopansa
6 Replies

10. Shell Programming and Scripting

Displaying Script command with output

How do you display the script command for a particular output result? Is there an editor that will allow for an echo or sysout of the script that causes an output result? We have hundreds of lines in the script, which we would like to see along with the output, and don't want to have to put in... (5 Replies)
Discussion started by: JeDi
5 Replies
Login or Register to Ask a Question