Sponsored Content
Top Forums Shell Programming and Scripting Echo not printing the variables with delimiters as required Post 302975961 by ramprabhum on Tuesday 21st of June 2016 11:55:58 PM
Old 06-22-2016
Lightbulb Echo not printing the variables with delimiters as required

This is the file which contains only neccessary values from the output of curl command i.e TEMP_FILE

Code:
        Proxy Hostname
        server0123.domain.com
        Proxy IP address
        XXX.XXX.XX.XX port 0000
        Proxy Version
        SGOS X.X.X.X
        Proxy Serial #
        000000001
        Client IP
        YYY.YYY.YYY.YYY
        Client Logged In As

        Groups user is member of

And here is the script which I have

Code:
#!/bin/bash

TEMP_FILE=/tmp/dashbosrd_details.txt
curl --silent --proxy <proxy_server_address:Port> --url http://dashbord.info/ | sed -e '/<d[td]\|^[[:blank:]]*$/!d; s/<[^>]*>//g; s/^ *//; /^\(Proxy\|Client\)/ s/$/:/' > $TEMP_FILE

Client_Hostname=`hostname --fqdn`
Proxy_Hostname=`awk '/Proxy Hostname/{getline;print;}' $TEMP_FILE`
Proxy_IP_address=`awk -F "port" '/Proxy IP address/{getline;print $1;}' $TEMP_FILE`
Proxy_IP_Port=`awk -F "port" '/Proxy IP address/{getline;print $2;}' $TEMP_FILE`
Proxy_Serial=`awk '/Proxy Serial #/{getline;print;}' $TEMP_FILE`
Client_IP=`awk '/Client IP/{getline;print;}' $TEMP_FILE`
Client_Logged_In_As=`whoami`


echo "$Client_Hostname" "|" "$Proxy_Hostname" "|" "$Proxy_IP_address" "|" "$Proxy_IP_Port" "|" "$Proxy_Serial" "|" "$Client_IP" "|" "$Client_Logged_In_As"

But the output of the script comes in a random or disorganized way as given below

Code:
 | <Client_Logged_In_As i.e whoami>YY.YYY.YYY.YYYort 0000 server0123.domain.com

Desired output:

Code:
myserver.domain.com | server0123.domain.com | XXX.XXX.XX.XX | 0000 | 000000001 | YYY.YYY.YYY.YYY | <Client_Logged_In_As i.e whoami>

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Help required on printing the line if third field is not a empty space

Hi Experts, I want to print the lines whose third field in non-empty/blank space. i.e. INPUT FILE/B] dcdccghjrry0yd cont dcdccttrk820529 cont rdekedfsSCr dcdccttrdky2d0y cont rdekedfsSC2 ... (3 Replies)
Discussion started by: krao
3 Replies

2. Shell Programming and Scripting

Help required on grep command(Skip the first few lines from printing in the output)

Hi experts I want the proper argument to the grep command so that I need to skip the first few lines(say first 10 lines) and print all the remaining instances of the grep output. I tried to use grep -m 10 "search text" file*. But this gives the first 10 instances(lines) of the search string.... (7 Replies)
Discussion started by: ks_reddy
7 Replies

3. UNIX for Dummies Questions & Answers

Help required on Printing of Numbers, which are missing in the range

Hi Experts, Need help on printing of numbers, which are missing in the range. Pls find the details below Input 1000000002 1000000007 1234007940 1234007946 Output 1000000003 1000000004 1000000005 1000000006 1234007941 (2 Replies)
Discussion started by: krao
2 Replies

4. Shell Programming and Scripting

Echo Variables and Text

I've been trying to get the syntax right so I can echo a $var and then text around it or after it. It either wont display text or $var or one overwrites the other at the beginning of the line. Trying to do something like this. var=1 echo $var"+1.1" #output expected 1+1.1 Its an older... (3 Replies)
Discussion started by: Grizzly
3 Replies

5. Shell Programming and Scripting

Extracting variables from echo

Hello all. I can not remember the command to extract a variable from the date command. Basically what I need to do is to store the values of date in variable and rearrange them. I can not remember the command or the syntax to do so. so.. date Mon Mar 8 06:57:19 GMT 2010 $1 $2 ... (12 Replies)
Discussion started by: adelsin
12 Replies

6. Shell Programming and Scripting

awk: Print fields between two delimiters on separate lines and send to variables

I have email headers that look like the following. In the end I would like to accomplish sending each email address to its own variable, such as: user1@domain.com='user1@domain.com' user2@domain.com='user2@domain.com' user3@domain.com='user3@domain.com' etc... I know the sed to get rid of... (11 Replies)
Discussion started by: tay9000
11 Replies

7. Shell Programming and Scripting

echo two variables like the paste command is not working

Dear all, I have two files like this file1 A B C D E F file2 1,2 3,4 5,6 I want this output output_expected A B 1,2 C D 3,4 E F 5,6 (3 Replies)
Discussion started by: valente
3 Replies

8. Shell Programming and Scripting

Searching and printing only required pattern

Hi all, i am trying to count the number of logical processors from the below output: # print_manifest | grep "logical processors" 8 cores, 16 logical processors per socket 2 logical processors (2 per socket) i just want to have below output : 16 2 also... (11 Replies)
Discussion started by: omkar.jadhav
11 Replies

9. Shell Programming and Scripting

Help required in printing in specific format

Hi All, I 'm matching two files based on the first 2 columns and then populate other fields along with subtraction of few fields. I have managed to get the output. However, is there a easier way in formatting the output as shown below instead of using additional printf for getting fixed width... (4 Replies)
Discussion started by: shash
4 Replies

10. Shell Programming and Scripting

Printing double quotes in echo command

Please help me to use echo or printf type of command to print some value from variable within double quotes - I want to print the double quote ( " ") also. I tried #!/bin/bash VALUE=some_value echo '{"value" : "$VALUE"}' I was expecting the above script would produce .. {"value" :... (3 Replies)
Discussion started by: atanubanerji
3 Replies
ppmtosixel(1)						      General Commands Manual						     ppmtosixel(1)

NAME
ppmtosixel - convert a portable pixmap into DEC sixel format SYNOPSIS
ppmtosixel [-raw] [-margin] [ppmfile] DESCRIPTION
Reads a portable pixmap as input. Produces sixel commands (SIX) as output. The output is formatted for color printing, e.g. for a DEC LJ250 color inkjet printer. If RGB values from the PPM file do not have maxval=100, the RGB values are rescaled. A printer control header and a color assignment table begin the SIX file. Image data is written in a compressed format by default. A printer control footer ends the image file. OPTIONS
-raw If specified, each pixel will be explicitly described in the image file. If -raw is not specified, output will default to com- pressed format in which identical adjacent pixels are replaced by "repeat pixel" commands. A raw file is often an order of magni- tude larger than a compressed file and prints much slower. -margin If -margin is not specified, the image will be start at the left margin (of the window, paper, or whatever). If -margin is speci- fied, a 1.5 inch left margin will offset the image. PRINTING
Generally, sixel files must reach the printer unfiltered. Use the lpr -x option or cat filename > /dev/tty0?. BUGS
Upon rescaling, truncation of the least significant bits of RGB values may result in poor color conversion. If the original PPM maxval was greater than 100, rescaling also reduces the image depth. While the actual RGB values from the ppm file are more or less retained, the color palette of the LJ250 may not match the colors on your screen. This seems to be a printer limitation. SEE ALSO
ppm(5) AUTHOR
Copyright (C) 1991 by Rick Vinci. 26 April 1991 ppmtosixel(1)
All times are GMT -4. The time now is 01:26 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy