12-01-2008
Need complex script, anyone up for a challenge?
Default shell is /usr/bin/zsh
Script will be running #!/bin/bash
Need to pull information from database while using other scripts already made (not by me).
Ok, so i need a script pulling certain information about a customer's router interfaces.
I am using a ROUTER-DNS-NAME as variable $1
I already figured out how to obtain an output similar to the following from the SCRIPT1 that is already made:
.34
.35
After i receive those numbers, i have to run a separate script using those numbers in the end of the command, here is an example output result needed:
SCRIPT2 $1 ANYTHING.34
Having a little trouble figuring out how to connect those together within one script file.
In order for me to get first numbers i had to do a pretty long set of commands:
SCRIPT2 $1 ANYTHING | grep "`SCRIPT1 $1 | grep -i $1 | grep SOMETHING1 | grep -v NULL | cut -d"(" -f2 | cut -d"." -f1`" | cut -d"r" -f2 | cut -d" " -f1
I have SCRIPT1 interface names within SCRIPT2 to get their numbers (.34, .35 - i need that period!), then use SCRIPT2 back with those numbers.
If i use: SCRIPT2 $1 ANYTHING - this will pull all the interface info.
here is the similar output of SCRIPT1:
NODE IP(DOMAIN) STATE
----------------------------------------------- ------------------ ------
ROUTER-DNS-NAME (INTERFACE0/0) NULL(1) SOMETHING4
ROUTER-DNS-NAME (INTERFACE0/0/0:1) NULL(1) SOMETHING1
ROUTER-DNS-NAME (INTERFACE0/0/0:1.100) IPADDESS(1) SOMETHING1
Much of my script will have to contain the text formatting as per customer table punctuation. None of the names, have any specific lenght, so had to use fields.
Please advise what else i need to explain in order to get some help here.
Thank you.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
How to I put my find command string into a script. It is currently to long to be entered manually at command line.
for FNAME in `find /unixsxxx/interface/x.x/xxxxxx -type f \( -name '*.KSH' -o -name '*.sh' -o -name '*.sql' -o -name '*.ksh' \) -exec grep -il xxx.xxx.xxx.xxx {} \;`; do C=`grep -c... (5 Replies)
Discussion started by: TimHortons
5 Replies
2. Shell Programming and Scripting
two tabulate files (A, B), each contents thousands and thousands lines with ids.
first find out contents with common ids in both A, B and print out into a file;
second find out contents with ids which only exist in file A and print out into a file. (4 Replies)
Discussion started by: ssshen
4 Replies
3. Shell Programming and Scripting
My script prints lines in which the entire line may be colored, and portions may also be colored. e.g.
Consider this to be one line:
$red some text in red $yellow abcd $end_yellow red text 1234 $blue some text $end_blue more red text $end_red
So using sed, I may based on condition 1,... (5 Replies)
Discussion started by: sentinel
5 Replies
4. Shell Programming and Scripting
hey... i had a big problem with my professor
i have 3 simple archives
in.txt -> had all timestamps of users logon (100lines)
ex. 111111
222222
333333
out.txt -> had all timestamps of users logof (100lines)
ex. 111113
222225
333332
commands.txt... (9 Replies)
Discussion started by: beandj
9 Replies
5. Shell Programming and Scripting
Hello,
I need to make shell script menu for my end users. There is like 100 scripts in system, and they need to run that scripts true one main script with user friendly menu.
Example, when user will run main menu script, it will get something like this on his screen:... (3 Replies)
Discussion started by: waso
3 Replies
6. Shell Programming and Scripting
picked this up from another thread.
echo 1st_file.csv; nawk -F, 'NR==FNR{a++;next} a{b++}
END{for(i in b){if(b-1&&a!=b){print i";\t\t"b}else{print "NEW:"i";\t\t"b} } }' OFS=, 1st_file.csv *.csv | sort -r
i need to use the above but with a slight modification..
1.compare against 3 month... (25 Replies)
Discussion started by: slashbash
25 Replies
7. Shell Programming and Scripting
Hello,
I need to make shell script menu for my end users. There is like 100 scripts in system, and they need to run that scripts true one main script with user friendly menu.
Example, when user will run main menu script, it will get something like this on his screen:... (1 Reply)
Discussion started by: waso
1 Replies
8. Shell Programming and Scripting
Hello to all in forum,
Maybe an awk expert could help me with this complex task for me.
I have the input shown below and I would like to get the output as follow:
- I would like the output separated by commas.
- The header is fixed and will be the same always.
- For the lines containing... (22 Replies)
Discussion started by: Ophiuchus
22 Replies
9. Shell Programming and Scripting
I have an FTP server with thousands of Invoices. All Invoices are in a folder called /volume1/MBSInvoices/
Monthly invoices are added to that folder every month.
Here is a sample filename of the Invoices:
invoice_1_20170101_10010052_10020052_10030052_JOHNDOE.pdf
the Account ID is the... (6 Replies)
Discussion started by: badr777
6 Replies
10. Shell Programming and Scripting
Hi All
Thanks for reviewing my question.
I have a sh script where I used an environmental variable for the directory for the file I need to check to ensure before executing a process.
I have confirmed the permissions and I can find the file if I use a hard coding of the directory. This is a... (5 Replies)
Discussion started by: rstojkovic68
5 Replies
cut(1) User Commands cut(1)
NAME
cut - cut out selected fields of each line of a file
SYNOPSIS
cut -b list [-n] [file...]
cut -c list [file...]
cut -f list [-d delim] [-s] [file...]
DESCRIPTION
Use the cut utility to cut out columns from a table or fields from each line of a file; in data base parlance, it implements the projection
of a relation. The fields as specified by list can be fixed length, that is, character positions as on a punched card (-c option) or the
length can vary from line to line and be marked with a field delimiter character like <TAB> (-f option). cut can be used as a filter.
Either the -b, -c, or -f option must be specified.
Use grep(1) to make horizontal ``cuts'' (by context) through a file, or paste(1) to put files together column-wise (that is, horizontally).
To reorder columns in a table, use cut and paste.
OPTIONS
The following options are supported:
list A comma-separated or blank-character-separated list of integer field numbers (in increasing order), with optional - to
indicate ranges (for instance, 1,4,7; 1-3,8; -5,10 (short for 1-5,10); or 3- (short for third through last field)).
-b list The list following -b specifies byte positions (for instance, -b1-72 would pass the first 72 bytes of each line). When -b
and -n are used together, list is adjusted so that no multi-byte character is split.
-c list The list following -c specifies character positions (for instance, -c1-72 would pass the first 72 characters of each line).
-d delim The character following -d is the field delimiter (-f option only). Default is tab. Space or other characters with special
meaning to the shell must be quoted. delim can be a multi-byte character.
-f list The list following -f is a list of fields assumed to be separated in the file by a delimiter character (see -d ); for
instance, -f1,7 copies the first and seventh field only. Lines with no field delimiters will be passed through intact (use-
ful for table subheadings), unless -s is specified.
-n Do not split characters. When -b list and -n are used together, list is adjusted so that no multi-byte character is split.
-s Suppresses lines with no delimiter characters in case of -f option. Unless specified, lines with no delimiters will be
passed through untouched.
OPERANDS
The following operands are supported:
file A path name of an input file. If no file operands are specified, or if a file operand is -, the standard input will be
used.
USAGE
See largefile(5) for the description of the behavior of cut when encountering files greater than or equal to 2 Gbyte (2**31 bytes).
EXAMPLES
Example 1: Mapping user IDs
A mapping of user IDs to names follows:
example% cut -d: -f1,5 /etc/passwd
Example 2: Setting current login name
To set name to current login name:
example$ name=`who am i | cut -f1 -d' '`
ENVIRONMENT VARIABLES
See environ(5) for descriptions of the following environment variables that affect the execution of cut: LANG, LC_ALL, LC_CTYPE, LC_MES-
SAGES, and NLSPATH.
EXIT STATUS
The following exit values are returned:
0 All input files were output successfully.
>0 An error occurred.
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Availability |SUNWcsu |
+-----------------------------+-----------------------------+
|CSI |Enabled |
+-----------------------------+-----------------------------+
|Interface Stability |Standard |
+-----------------------------+-----------------------------+
SEE ALSO
grep(1), paste(1), attributes(5), environ(5), largefile(5), standards(5)
DIAGNOSTICS
cut: -n may only be used with -b
cut: -d may only be used with -f
cut: -s may only be used with -f
cut: cannot open <file> Either file cannot be read or does not exist. If multiple files are present, processing continues.
cut: no delimiter specified Missing delim on -d option.
cut: invalid delimiter
cut: no list specified Missing list on -b, -c, or -f option.
cut: invalid range specifier
cut: too many ranges specified
cut: range must be increasing
cut: invalid character in range
cut: internal error processing input
cut: invalid multibyte character
cut: unable to allocate enough memory
SunOS 5.10 29 Apr 1999 cut(1)