Sponsored Content
Top Forums Shell Programming and Scripting [bash] jump from one txt file to another Post 302317076 by laurens on Monday 18th of May 2009 04:01:09 AM
Old 05-18-2009
Hi Franklin Smilie

As I don't really see the bomen door het bos anymore in the bash script... I don't see where it went wrong now.
I adjusted the script like you advised:

Code:
...
EOT
awk '{ sub("\r$", ""); print }' ftpservers.txt > unixfile.txt
awk '
NR%3==1{a[++i]=$0}
NR%3==2{u[++i]=$0}
NR%3==0{p[++i]=$0}
END{for(f in a){print a[f], u[f], p[f], a[f] "_folderlist.txt"}}' unixfile.txt | 
while read ipaddress user passwd flist
do
  while read dir
  do
         if [[ $ipaddress =~ ^192\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
      echo "private IP - skipping"
else
ftp -n -v $ipaddress <<EOT
ascii
user $user $passwd
prompt
...

This is the output:
Code:
do
  while read dir
  do
        if [[ $ipaddress =~ ^192\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
          echo "private IP - skipping"
else
ftp -n -v $ipaddress <<EOT
        fi
  done < $flist
done
++ awk '
NR%3==1{a[++i]=$0}
NR%3==2{u[++i]=$0}
NR%3==0{p[++i]=$0}
END{for(f in a){print a[f], u[f], p[f], a[f] "_folderlist.txt"}}' unixfile.txt
++ read ipaddress user passwd flist
./bash.sh: line 32: $flist: ambiguous redirect
++ read ipaddress user passwd flist
./bash.sh: line 32: $flist: ambiguous redirect
++ read ipaddress user passwd flist
./bash.sh: line 32: $flist: ambiguous redirect
++ read ipaddress user passwd flist
./bash.sh: line 32: $flist: ambiguous redirect
++ read ipaddress user passwd flist
./bash.sh: line 32: $flist: ambiguous redirect
++ read ipaddress user passwd flist
./bash.sh: line 32: $flist: ambiguous redirect
++ read ipaddress user passwd flist
./bash.sh: line 32: $flist: ambiguous redirect
++ read ipaddress user passwd flist
./bash.sh: line 32: $flist: ambiguous redirect
++ read ipaddress user passwd flist
./bash.sh: line 32: $flist: ambiguous redirect
++ read ipaddress user passwd flist
./bash.sh: line 32: $flist: ambiguous redirect
++ read ipaddress user passwd flist
./bash.sh: line 32: $flist: ambiguous redirect
++ read ipaddress user passwd flist
./bash.sh: line 32: $flist: ambiguous redirect
++ read ipaddress user passwd flist
./bash.sh: line 32: $flist: ambiguous redirect
++ read ipaddress user passwd flist
./bash.sh: line 32: $flist: ambiguous redirect
++ read ipaddress user passwd flist
./bash.sh: line 32: $flist: ambiguous redirect
++ read ipaddress user passwd flist
./bash.sh: line 32: $flist: ambiguous redirect
++ read ipaddress user passwd flist
./bash.sh: line 32: $flist: ambiguous redirect
++ read ipaddress user passwd flist
./bash.sh: line 32: $flist: ambiguous redirect
++ read ipaddress user passwd flist
./bash.sh: line 32: $flist: ambiguous redirect
++ read ipaddress user passwd flist
./bash.sh: line 32: $flist: ambiguous redirect
++ read ipaddress user passwd flist
./bash.sh: line 32: $flist: ambiguous redirect
++ read ipaddress user passwd flist
rm unixfile.txt
++ rm unixfile.txt

Thanks again
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Binary txt file received when i use uuencode to send txt file as attachment

Hi, I have already read a lot of posts on sending attachments in unix...but none of them were of help for my problem...so here goes.. i wanna attach a text file and send to a mail id..used the following code : uuencode "$File1" "$File1" ;|mail -s "$Mail_sub" abc@abc.com it works... (2 Replies)
Discussion started by: ash22
2 Replies

2. Shell Programming and Scripting

Jump to a specific place in a file?

If I cat a file And want to go to the first instance of a particular value - what command would I use? And then from that point where I jumped to search for another value - but only search from that point forward not before the file? Thanks~ (2 Replies)
Discussion started by: llsmr777
2 Replies

3. Shell Programming and Scripting

bash script to sort a txt file

I am writing a script to write to and a sort txt file. After I sort the file I want to add 2 to each line of the file. My script thus far is #!/bin/bash cat > /ramdisk/home/stux/unsortedints.out COUNT=0 FILE =/ramdisk/home/stux/unsortedints.out for i in {1..100} do NUMBER = $ echo $NUMBER... (3 Replies)
Discussion started by: puttyirc
3 Replies

4. UNIX for Advanced & Expert Users

vimdiff jump to other file or switch windows

This took me quite awhile to find so I wanted to share this with other people. To switch windows in vimdiff or to navigate windows in vimdiff or to change windows in vimdiff try the following: The ":vertical" command can be inserted before another command that splits a window. ... (0 Replies)
Discussion started by: cokedude
0 Replies

5. Shell Programming and Scripting

awk append fileA.txt to growing file B.txt

This is appending a column. My question is fairly simple. I have a program generating data in a form like so: 1 20 2 22 3 23 4 12 5 43 For ever iteration I'm generating this data. I have the basic idea with cut -f 2 fileA.txt | paste -d >> FileB.txt ???? I want FileB.txt to grow, and... (4 Replies)
Discussion started by: theawknewbie
4 Replies

6. Shell Programming and Scripting

Need to append the date | abcddate.txt to the first line of my txt file

I want to add/append the info in the following format to my.txt file. 20130702|abcd20130702.txt FN|SN|DOB I tried the below script but it throws me some exceptions. <#!/bin/sh dt = date '+%y%m%d'members; echo $dt+|+members+$dt; /usr/bin/awk -f BEGIN { FS="|"; OFS="|"; } { print... (6 Replies)
Discussion started by: harik1982
6 Replies

7. UNIX for Dummies Questions & Answers

Write pid and command name to a txt file while executing a bash script

Hi All, Just have a requirement, I am executing a bash shell script, my requirement is to catch the pid and job name to a txt file in the same directory, is there anyway to do it? please help me out. Regards Rahul ---------- Post updated at 08:42 AM ---------- Previous update was at... (2 Replies)
Discussion started by: rahulkalra9
2 Replies

8. Shell Programming and Scripting

Call a Perl script within a bash script and store the ouput in a .txt file

I'm attempting to write a bash script that will create a network between virtual machines. It accepts three arguments: an RSpec that describes the network topology, and two list of machines (servers and clients). I have a (working) Perl script that I want to call. This Perl script takes an RSpec... (6 Replies)
Discussion started by: mecaka
6 Replies

9. Shell Programming and Scripting

Desired output.txt for reading txt file using awk?

Dear all, I have a huge txt file (DATA.txt) with the following content . From this txt file, I want the following output using some shell script. Any help is greatly appreciated. Greetings, emily DATA.txt (snippet of the huge text file) 407202849... (2 Replies)
Discussion started by: emily
2 Replies

10. Shell Programming and Scripting

Bash incert line from 1.txt to 2.txt

i would like to insert a line from 2.txt into 1.txt between " and " or a way of adding to the end of each line " _01_ and have the numbers correspond to the line # 1.txt= foofoo "" _01_ foofoo "" _02_ foofoo "" _03_ foofoo "" _04_ 2.txt= ... (6 Replies)
Discussion started by: klein
6 Replies
APSFILTER-BUG(1)					    BSD General Commands Manual 					  APSFILTER-BUG(1)

NAME
apsfilter-bug -- create a half-automatic bug report for apsfilter SYNOPSIS
apsfilter-bug OPTIONS
none DESCRIPTION
With the apsfilter-bug script you can automatically create a bug report for apsfilter(1). A template report file is created which you can edit with your favourite editor ( emacs(1) by default, or whatever is entered in the environment variable EDITOR ). You will see a couple of lines starting with '#'; these lines will be removed before the report is sent. So if you want to use the '#' char- acter at the beginning of a line, just indent it with a space. A very important piece of the bug report is the debugging log created by aps2file(1), probably with a command like aps2file -D -o /dev/null [-P...] [-Z...] [input] 2> log.txt Unless you don't even have a chance to create a debugging log, it is crucial for serious bug hunting. After you have filled in as much (useful) information as possible, you must save the file under its original name, then exit your editor. If you invoked apsfilter-bug by accident, or if you need some additional system information to include into the bug report, just exit your editor without saving the file. NOTES
In addition to the stuff you've edited, some more information is appended to the bug report automatically: apsfilter version 7.2.6-stable ghostscript version (from 'gs --version') system id (from 'uname -a') configure options --prefix=/usr --sysconfdir=/etc --mandir=/usr/share/man --with-awk=/usr/bin/awk --with-sendmail=/usr/sbin/sendmail shell executable /bin/bash awk executable /usr/bin/awk sendmail executable /usr/sbin/sendmail FILES
/usr/bin/aps2file script to create debugging output SEE ALSO
apsfilter(1), aps2file(1) BUGS
See apsfilter software center - http://www.apsfilter.org/ - for new versions, bugfixes and known bugs. Please use the new tool apsfilter-bug(1) to release bug- or problem reports. It automatically presents you a form in an editor window which asks you some standard questions. If you save and quit the editor session, then this report is sent automatically via e-mail to the proper apsfilter mailinglist. If apsfilter fails to print something or prints it in a way you wouldn't expect and you want to report an apsfilter error then please save the debugging output of one print session using the new aps2file(1) utility by typing aps2file -D -Z options file > /dev/null 2> file.debug and including the debugging output in the file file.debug into the edit session of the apsfilter-bug utility, so that it is included into the mail to the apsfilter mailinglist. Please note that you need to run /bin/sh (Bourne Shell), bash or a compatible shell, so that the above mentioned output redirection works. Under C-shell (/bin/csh) or tcsh it would't work. If you don't know, then simply make sure you use the Bournce shell by typing /bin/sh or bash, then you should have no problems with redirection of stdout and stderr (> /dev/null 2> file.debug). DOCUMENTATION
See official apsfilter homepage http://www.apsfilter.org/handbook.html Apsfilter Handbook including the Frequently Asked Questions (FAQ) USER FORUM
Please send questions to the official apsfilter help channel apsfilter-help@apsfilter.org. The above section BUGS and the file HOWTO-BUGREPORTS tells you how to report bugs. If you want to know how to troubleshoot your apsfilter installation, please read the manpage aps2file(1) and apsfilter-bug(1) as well as the Apsfilter Handbook carefully. HISTORY
The apsfilter-bug manpage has been written by Michael LoBin <phallobst@web.de> and first appeared in apsfilter V 7.1.0. BSD
Dec 26, 2001 BSD
All times are GMT -4. The time now is 01:02 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy