Programming :: While Read Line - Doesn't Work With Ssh In The Loop Body

Mar 26, 2010

I am trying to read the names of hosts from a file and do a ssh to see if processes are all running or not.

Here is the outer loop that is causing problem:

hosts.lst is a text file that has the host names in each line.

The problem is that the loop just breaks after the first run. Somehow while read line becomes invalid when the body of the loop does the ssh and returns.

View 5 Replies


ADVERTISEMENT

Programming :: Read A File With A While Loop?

Apr 25, 2010

ITT and am just lurning about scripting and need to read a file and output the file to the screen. We need to do this with a while loop.

View 5 Replies View Related

Programming :: Bash For Loop - All Responses On One Line

Nov 18, 2010

I'm writing a mass snmp toner check which polls any toners available to be snmp polled, however when using a loop statement I get the results on different lines; which sounds good, however the tool I use to check with (nagios) ignores the new lines.

Is there any way I can get the output on one line? Also, I need to raise a fault if any of the toners are below a specific level (with nagios you raise faults with the exit code) - any way I can do this without exiting the loop. Code below with bits and bobs commented out.

Code:
check_ink_levels ()
{
for ID in $INKS
do

[Code].....

View 10 Replies View Related

Programming :: Open Two Text Files - Read Them Line By Line And Update Parameters Of The 3rd File ?

Oct 18, 2010

I have two txt files containing x and y coordinates: xcoord.txt & ycoord.txt. I need to open them; read them line by line to get each coordinate; then each time I need to update Xs and Ys parameters inside another file called "dc.in" with the grabbed values.

Finally each time I need to run two exe files ( dc_2002 and st_vac) and produce corresponding output for each Xs and Ys ( dc.in is an input file for this exe files)

I have written the following code but it does not work:

View 14 Replies View Related

Programming :: Bash: Read A Text File Line By Line?

Jul 7, 2011

bash 3.1.17(2) I'm trying do write a shell script which must operate on each line of an ASCII text file. So, all the code must be inside a loop, and inside the loop, the first thing should be to read the next line from the file. I have the bash read command. But it reads from stdin. Any way to make read from a file?

View 6 Replies View Related

General :: For Loop Or While Loop To Read The Fields Of A File?

Sep 1, 2010

I have a mytext file with month and year as two separate fields. likemytext fil

08 2010
09 2010
10 2010
........
........
........

I want to read the values of each field i.e., month and year into an awk script.

View 10 Replies View Related

Programming :: Perl Script To Read Line By Line

Aug 2, 2011

I just learn perl script.May i know how to simplify the code below especially in the red color part? i saw some examples in internet, they use "next" command.

View 20 Replies View Related

Programming :: QTimer To Read A File Line After Line?

Mar 25, 2010

I need a qtimer to trigger reading of a file line by line, I have the code sort of running with the timer trigger but qtimer will just read the first line over and over as it is now.

Here is the code so far:

self.lcdtimer = QTimer()
self.connect(self.pushButton85,SIGNAL("clicked()"),self.update)
self.connect(self.lcdtimer, SIGNAL("timeout()"), self.lcdxyz)

Code:

def lcdxyz(self):
import time
import os

[code]....

View 12 Replies View Related

Programming :: Read In Stdin And Ping Line By Line?

Jan 8, 2010

Code:

#!/usr/bin/perl
use 5.10.0;
use strict;
use warnings;
use Net::Ping;

[code]....

View 1 Replies View Related

Programming :: How To Read Line By Line In A File In C

Feb 5, 2010

i want to read line by line in a files in C language actually my porblem is i have a one file cotains

if iam using fgets, it is reading each time AT only it does not moving to Ok in that file

View 6 Replies View Related

Programming :: Read File Line By Line?

Mar 23, 2011

so I have a script that creates couple of txt files. First file output is something like below..

cn=test,ou=something,ou=some,o=org
cn=testa,ou=something,ou=some,o=org
cn=testb,ou=something,ou=some,o=org

second file output is something like below..
usera
userb
userc

Quote:

userdn=`ldapsearch -x -h $server -LLL "(objectclass=person)" dn | grep dn: | cut -d" " -f2 > userdn.txt

for i in $(cat userdn.txt);do

ldapsearch -h $server -p 389 -x -D $admid -w $admpwd -s one -b "$userdn" dn | grep dn: | cut -d" " -f2 | cut -d"=" -f2 | cut -d"," -f1 > user.txt

for i $(cat user.txt);do

echo "$userdn"
done
done

when I ran both ldapsearch commands invidually, they work fine. But when I ran script, I got first file correctly but not the second one. It looks like its not reading the first file correctly and not setting the variable ($userdn) value correctly in the second ldapseach command. I want read first file first line and run the second ldapsearch and continues, then read the second line..and so on.

View 3 Replies View Related

Programming :: Imagemagick With For Loop On The Commandline Does Not Work

May 26, 2011

I have images in jpg format

Code:

CIMG0100.jpg
...
...
CIMG0131.jpg

I used imagemagick to convert the files to gif with the following command

Code:

for i in {100..131}; do convert CIMG0$i.jpg CIMG0$i.gif; done # works

This worked like expected, but when afterwards I wanted to scale the images

Code:

for i in {100..131}; do convert -scale 25% CIMG00$i.gif CIMG00$i_scaled.gif; done # works not it seems the system is working for about half a minute, but I get no output. The single command

Code:

convert -scale 25% CIMG100.gif CIMG100_scaled.gif # works

works as expected and gives me a scaled image. What does the convert command do in the second case? is the for-loop wrong?

View 2 Replies View Related

Programming :: Read Two Files Word By Word At A Time Using Any Loop By Shell Script?

Mar 4, 2010

Well, I am facing one issue:How can i read two files word by word at a time using any loop as i need word by word comparision in shell script?Please let me know pseudo code.

View 14 Replies View Related

Programming :: Bash - Read Content Of File To Variable And Use This Variable In For Loop ?

Aug 21, 2009

I'm trying to read content of file to variable and use this variable in for loop. The problem is, when I have c++ comment style in file - /*. Spaces in line are also interpreted as separated lines.

For example:

Code:

Changing $files to "$files" eliminate these problems but causes that whole content of variable is treated as one string (one execution of loop).

View 6 Replies View Related

Programming :: Email Body Is Not Being Sent?

Feb 11, 2010

why the Message-Body is not shown when email is recieved using the PHP Script as given below? However, I can see the Attachment and the Subject Line properly. If I send an email to my Internal ID then everything is fine. But when the same email is sent to an external id such @someOtherCompany then the Message in the Body is not sent. how to seperate the $message varibale from being used in the $header part abd form it in HTML in a way that the Attachment part, and the subject part are not disturbed?

[Code]...

View 14 Replies View Related

Programming :: Add Date/Time To The Message Body?

Sep 6, 2009

- how to add the date/time to the email (message body)

- how to as the user to add a picture

- how add on an error page a button to send it back to the form so that the input does not get lost

Here the program so far:

<?php
/*
CHFEEDBACK.PHP Feedback Form PHP Script Ver 2.15.0
Generated by thesitewizard.com's Feedback Form Wizard 2.15.0.

[code]....

View 1 Replies View Related

Programming :: Read The Presence Of A Blank Line In Gcc?

Apr 20, 2010

in gcc how to read a blank line ie a string of length 0.

my code: Code:
#include<stdio.h>
#include<string.h>
#include<string>
using namespace std;
[Code]....

View 4 Replies View Related

Programming :: Read A Line From A Txt File In A Script?

Dec 9, 2010

have been playing around with a script for a few hours and now I need to be able to output the lines in a text file one by one to be used later in the script.What it gonna do is to read a log file and grep the usernames, then write them to a file, and then run one script for each user, to search for more information about them in the log.But I don't know how to output a single line from a file, and google does not return any solution.

View 3 Replies View Related

Programming :: Read In A File 1 Line At A Time?

Oct 22, 2010

i am trying to read in a file 1 line at a time and for some reason it stops printing out at about line 62,000.

i am doing this:
Code:
while(fgets(c0, 1085, fstream0) != NULL)

but after about 62,0000 lines it stops printing. no seg-fault, no core dump. it just stops printing to the terminal then returns me to the command line after a couple of minutes. as a hack i am doing split -l 50000 on the input and calling my program 5 times.is there some limitation on fgets that i am not understanding ?

View 8 Replies View Related

Programming :: Read Each Line Of A File As Input?

Jun 21, 2011

I'm writing a program which now accepts user input:

Code:
echo "Enter a date in the format YYYY MM DD hh mm ss."

read gregyr gregmo gregdy greghr gregmn gregsc This lets the user input a date and time, such as 2011 06 21 15 12 45, and have each number assigned to their corresponding variable. Later in the program, these variables are put into an equation, and then the terminal spits out the answer. Now I have to have the program read all of the lines from a text file, which is in this format, assign the variables.

View 7 Replies View Related

Programming :: Read A File That Counts Each Line And Numbers

May 13, 2010

I ran into it while google Segmentation Fault. I'm writing a simple C program that reads a file that counts each line and numbers it then writes to a file called sdout. I copyed my program mostly from the text book but im still having problems. Heres my code:

#include <stdio.h>
#include <stdlib.h>
void new_line(FILE *, FILE *);
int main(char *argv)

[Code]....

View 14 Replies View Related

Programming :: Read A Blank Line Ie A String Of Length 0?

Apr 19, 2010

in gcc how to read a blank line ie a string of length 0.my code:

Code:
#include<stdio.h>
#include<string.h>

[code]...

View 3 Replies View Related

Programming :: Looping Using While Read Line And A Variable Instead Of A File?

Sep 24, 2010

I created the following.

x="top
middle
bottom"

I would like to make the following work.

while read line
do
echo $line
done

instead of importing a file I would like to use the variable $x I tried using pipes, but with no luck. My goal is to read one line at a time, but not have to export my data to another file, I would like to keep it all within one script.

View 3 Replies View Related

Programming :: Html Tags Inside PHP Mail Body Message?

Mar 9, 2010

Trying to write a small php program to send emails using a form. I have collected all the information in php variables and I can send the mails just fine. But I need some neat and clean formatting for the mail that is received and hence thought html tables would be nice. But all the html tags are received as plain text and not html though I have mentioned in headers content-type to be html. Any links? If anyone can put some light on it? I thought that html tags would just work fine without much issue. I have tried same with asp and it worked.

PS: I am no programmer. Just trying my hands out on some php.

Edit: I am using a php mailer class from php classes to send mails. I need some way to use an external smtp server for sending mails. I have seen pear but I do not want to use pear. It is not available on the server I am testing and it is not possible for me to install it. I do not have access to install pear and can not ask to install it.

View 7 Replies View Related

Programming :: Bash Shell Read User Argument From Command Line And Test It

Aug 29, 2010

Trying to create a small script that will read user's input, test if user entered some input and if not display some message or display a text using user's input.

The script is the following but i get an error saying "[: 6: =: argument expected"

View 12 Replies View Related

Ubuntu Installation :: Upgrade - Can't Read Anything - Touchpad Doesn't Work

Feb 8, 2010

This weekend I did a distribution upgrade to Karmic, but it didn't go very well. Upon reboot, I see a white ubuntu logo on a black screen. I hear the speakers pop, and the screen flashes several times, sorta like the blank screen is maybe changing video modes. After a while I see what I think is garbled text but is unreadable, and it looks like I can log on even though I can't read anything. Now, booting into recovery mode gets me to a readable prompt. There are no upgrades to apply. Typing gdm from here gets me to the desktop just fine. Also when booting, if I choose an earlier kernel the system boots fine also, except the touchpad doesn't work.

View 1 Replies View Related

Ubuntu Multimedia :: Line-in Doesn't Work Lucid

Nov 1, 2010

Using Lucid and most things seem to be going OK but I can't get the computer to take the line-in signal.

It's an AsRock M3A785GMH/128M mainboard (ALC888 Audio) and I'm on Lucid 64-bit.

I've checked the jack's in the right socket, that the input is elected in both the normal ALSA volume control and pulse, and that the volume controls are turned up.

I know also that there is a signal going into the line-in lead!

View 3 Replies View Related

Programming :: Create A Simple Program With Will Continually Read Input From The User Until They Enter A Blank Line?

Apr 6, 2011

basically i have to create a simple program with will continually read input from the user until they enter a blank linei know how to read in certain input but not sure how to get it continually in a loop

View 2 Replies View Related

Fedora :: Bind C-u To Kill-whole-line In Bash Doesn't Work

Mar 19, 2010

I'd like control-u to erase the whole line, instead of only erasing backwards from the current point. I tried

bind -r "C-u"
bind -r C-u
bind -r ^U

to erase the current binding for control-u, but after running any / all of the above, bind -p still tells me

"C-u": unix-line-discard

bind "C-u":kill-whole-line doesn't work either. How can I change the binding of control-u to kill-whole-line?

View 2 Replies View Related

Programming :: GDB Doesn't Provide The Correct Line In The Source Code

Jan 23, 2011

I found a strange problem when I use gdb in eclipse to debug. When I step in the program, the register RIP(I'm using x86_64 machine and that's EIP in 32 bit mode) shows correctly but the line stepping in the source code may be far from the correct line. For example, when there is no loop in the source code, the RIP keeps on increasing and the current instruction pointer goes back to several lines back. I'm sure the source code is the right one because I when I checked the memory and local variables after several lines the values are all correct. The source code has many empty lines and does it matters with GDB?

View 3 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved