Sponsored Content
Operating Systems HP-UX Unable to pass a space inside a variable shell scripting Post 302843635 by Don Cragun on Wednesday 14th of August 2013 08:51:36 AM
Old 08-14-2013
First, this all seems to be a very convoluted way of getting output from the command:
Code:
date '+%b %e'

Second, if you save the output from the above command in a variable:
Code:
p=$(date '+%b %e')

and then print that value using echo without quotes, you are throwing away the fact there the date command will put two spaces between the abbreviated month name and the day of the month for the 1st nine days of every month. If you want to preserve the spacing, use:
Code:
echo "$p"

not:
Code:
echo $p

There is a big difference between being able to pass a space in a variable and getting the shell to recognize that two spaces are different that one space when you subject the contents of that variable to word splitting.

To get what you want out of the log file, there are lots of ways to do it depending on your shell. With any standards conforming shell (such as bash or ksh), try:
Code:
tail -n 1 /var/adm/syslog/syslog.log|(
    read abmon dom
    printf "%s %2s" $abmon $dom
)

or:
Code:
tail -n 1 /var/adm/syslog/syslog.log|awk '{print substr($0, 1, 6)}'


Last edited by Don Cragun; 08-14-2013 at 10:12 AM.. Reason: Add way to get desired data from log file.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

How to Pass variable to shell Script

Hi , i am beginner to Unix, I have one small script which execute java programme,it has java command input output structure . Right now i have given Input output structure manually that is on same directory, now how can i pass that by commandline #!/bin/sh java Classjava input.txt... (5 Replies)
Discussion started by: sam70
5 Replies

2. Shell Programming and Scripting

how to pass a variable to an update sql statement inside a loop

hi all, i am experiencing an error which i think an incorrect syntax for the where clause passing a variable was given. under is my code. sqlplus -s ${USERNAME}/${PASSWORD}@${SID} << END1 >> $LOGFILE whenever sqlerror exit set serveroutput on size 1000000 declare l_rc ... (0 Replies)
Discussion started by: ryukishin_17
0 Replies

3. Shell Programming and Scripting

nested double quota and white space inside variable

I have a question about nested double quotes. Any help is appreciated. Here are my commands on Mac OS. # string="Ethernet \"USB Ethernet\" \"Bluetooth DUN\" AirPort FireWire \"Bluetooth PAN\"" # echo $string Ethernet "USB Ethernet" "Bluetooth DUN" AirPort FireWire "Bluetooth PAN" #... (3 Replies)
Discussion started by: lindazhou
3 Replies

4. Shell Programming and Scripting

Not able to store command inside a shell variable, and run the variable

Hi, I am trying to do the following thing var='date' $var Above command substitutes date for and in turn runs the date command and i am getting the todays date value. I am trying to do the same thing as following, but facing some problems, unique_host_pro="sed -e ' /#/d'... (3 Replies)
Discussion started by: gvinayagam
3 Replies

5. Shell Programming and Scripting

Pass shell variable to gnuplot

Hi I am plotting a series of CDFs using gnuplot using plot "data" u 1:(1./x.) smooth cumulative I am doing this over many files and I need to tune the x value to the number of lines that meets a particular condition. Is it possible to get the line count from shell using cat file | grep... (7 Replies)
Discussion started by: jamie_123
7 Replies

6. Shell Programming and Scripting

unable to pass value to user prompt from calling shell script

This is my script structure main script calls configure script which needs to be run as a different user and the configure script calls my application installation script. the application instruction script prompts the user for a directory which I need to pass from my main or configure script. ... (4 Replies)
Discussion started by: cmastays
4 Replies

7. Shell Programming and Scripting

How to pass current year and month in FOR LOOP in UNIX shell scripting?

Hi Team, I have created a script and using FOR LOOP like this and it is working fine. for Month in 201212 201301 201302 201303 do echo "Starting the statistics gathering of $Month partitions " done But in my scripts the " Month " variable is hard-coded. Can you please any one... (3 Replies)
Discussion started by: shoan
3 Replies

8. Shell Programming and Scripting

Unable to pass shell script variable to awk command in same shell script

I have a shell script (.sh) and I want to pass a parameter value to the awk command but I am getting exception, please assist. diff=$1$2.diff id=$2 new=new_$diff echo "My id is $1" echo "I want to sync for user account $id" ##awk command I am using is as below cat $diff | awk... (2 Replies)
Discussion started by: Ashunayak
2 Replies

9. Shell Programming and Scripting

Unable to pass send command in shell script

I am trying to automate a testcase . I am installing some software and it waits for user input after displaying "Do you want to continue ? " I am trying to do this in shell scripting. #!/bin/bash #!/usr/bin/expect -f /usr/bin/expect << EOF spawn apt-get install openjdk-7-jdk expect "*Do you... (1 Reply)
Discussion started by: Abdul Navaz
1 Replies

10. Shell Programming and Scripting

Unable to pass value from .Shell script to .SQL file

Hi All, I am new to shell script. I am trying to pass value from .sh file to .sql file . But I am able to run the .sql file from .sh file with values in sql file. But I am unable to pass the values from .sh file. can some one please help to resolve this. here is my .sh file s1.sh ... (4 Replies)
Discussion started by: reddy298599
4 Replies
Graphics::Primitive::Component(3pm)			User Contributed Perl Documentation		       Graphics::Primitive::Component(3pm)

NAME
Graphics::Primitive::Component - Base graphical unit DESCRIPTION
A Component is an entity with a graphical representation. SYNOPSIS
my $c = Graphics::Primitive::Component->new({ origin => Geometry::Primitive::Point->new({ x => $x, y => $y }), width => 500, height => 350 }); LIFECYCLE
prepare Most components do the majority of their setup in the prepare. The goal of prepare is to establish it's minimum height and width so that it can be properly positioned by a layout manager. $driver->prepare($comp); layout This is not a method of Component, but a phase introduced by the use of Layout::Manager. If the component is a container then each of it's child components (even the containers) will be positioned according to the minimum height and width determined during prepare. Different layout manager implementations have different rules, so consult the documentation for each for details. After this phase has completed the origin, height and width should be set for all components. $lm->do_layout($comp); finalize This final phase provides and opportunity for the component to do any final changes to it's internals before being passed to a driver for drawing. An example might be a component that draws a fleuron at it's extremities. Since the final height and width isn't known until this phase, it was impossible for it to position these internal components until now. It may even defer creation of this components until now. It is not ok to defer all action to the finalize phase. If you do not establish a minimum hieght and width during prepare then the layout manager may not provide you with enough space to draw. $driver->finalize($comp); draw Handled by Graphics::Primitive::Driver. $driver->draw($comp); METHODS
Constructor new Creates a new Component. Instance Methods background_color Set this component's background color. border Set this component's border, which should be an instance of Border. callback Optional callback that is fired at the beginning of the "finalize" phase. This allows you to add some sort of custom code that can modify the component just before it is rendered. The only argument is the component itself. Note that changing the position or the dimensions of the component will not re-layout the scene. You may have weird results of you manipulate the component's dimensions here. class Set/Get this component's class, which is an abitrary string. Graphics::Primitive has no internal use for this attribute but provides it for outside use. color Set this component's foreground color. fire_callback Method to execute this component's "callback". get_tree Get a tree for this component. Since components are -- by definiton -- leaf nodes, this tree will only have the one member at it's root. has_callback Predicate that tells if this component has a "callback". height Set this component's height. inside_bounding_box Returns a Rectangle that defines the edges of the 'inside' box for this component. This box is relative to the origin of the component. inside_height Get the height available in this container after taking away space for padding, margin and borders. inside_width Get the width available in this container after taking away space for padding, margin and borders. margins Set this component's margins, which should be an instance of Insets. Margins are the space outside the component's bounding box, as in CSS. The margins should be outside the border. maximum_height Set/Get this component's maximum height. Used to inform a layout manager. maximum_width Set/Get this component's maximum width. Used to inform a layout manager. minimum_height Set/Get this component's minimum height. Used to inform a layout manager. minimum_inside_height Get the minimum height available in this container after taking away space for padding, margin and borders. minimum_inside_width Get the minimum width available in this container after taking away space for padding, margin and borders. minimum_width Set/Get this component's minimum width. Used to inform a layout manager. name Set this component's name. This is not required, but may inform consumers of a component. Pay attention to that library's documentation. origin Set/Get the origin point for this component. outside_height Get the height consumed by padding, margin and borders. outside_width Get the width consumed by padding, margin and borders. finalize Method provided to give component one last opportunity to put it's contents into the provided space. Called after prepare. padding Set this component's padding, which should be an instance of Insets. Padding is the space inside the component's bounding box, as in CSS. This padding should be between the border and the component's content. page If true then this component represents stand-alone page. This informs the driver that this component (and any children) are to be renderered on a single surface. This only really makes sense in formats that have pages such as PDF of PostScript. prepare Method to prepare this component for drawing. This is an empty sub and is meant to be overridden by a specific implementation. preferred_height Set/Get this component's preferred height. Used to inform a layout manager. preferred_width Set/Get this component's preferred width. Used to inform a layout manager. to_string Get a string representation of this component in the form of: $name $x,$y ($widthx$height) visible Set/Get this component's visible flag. width Set/Get this component's width. AUTHOR
Cory Watson, "<gphat@cpan.org>" BUGS
Please report any bugs or feature requests to "bug-geometry-primitive at rt.cpan.org", or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Geometry-Primitive <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Geometry-Primitive>. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. COPYRIGHT &; LICENSE Copyright 2008-2009 by Cory G Watson. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.12.3 2011-06-02 Graphics::Primitive::Component(3pm)
All times are GMT -4. The time now is 06:27 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy