Sponsored Content
Full Discussion: Shell script question
Top Forums Shell Programming and Scripting Shell script question Post 302938968 by ramkumar15 on Friday 20th of March 2015 11:28:43 AM
Old 03-20-2015
Shell script question

As per code it is getting matched. not sure why it assigning to cols=0.

Any inputs please.

Input : passed is
Code:
 
shell.sh c tablename.

Code:
 
if [$1=c]; then
cols=1
table=$2
else
cols=0
table=$1
fi

Output:

Code:
 
[interactive mode output:
 
+ [c=c]
dcs.sh[3]: [c=c]:  not found
+ cols=0
+ table=c

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

shell script question

I am using ksh. There is a report having amounts in the following format, 34343.67- 2343.45 23434.89- I want to sum up all the amounts. For this I first need to find out if there is a minus sign at the end and prefix it before summing up. How to achieve this? I thought of using an... (2 Replies)
Discussion started by: tselvanin
2 Replies

2. Shell Programming and Scripting

Shell script question

Hello, i am doing a project for school and i cannot figure out whats wrong with my 2 programs they dont seem to work at all. the first program is called isprime and naturally it checks to see if hte number is prime or not here is my code: #!/usr/bin/bash num=$1 echo you typed if ... (2 Replies)
Discussion started by: jbou1087
2 Replies

3. UNIX for Dummies Questions & Answers

Linux Shell Question: how to print the shell script name ?

Suppose I have a script named "sc.sh" in the script how to print out its name "sc.sh"? (3 Replies)
Discussion started by: meili100
3 Replies

4. Shell Programming and Scripting

Shell Script question

Hello Experts, I am new at this and need some help. I am looking for a delete command that allows me after I grep for the hostname to delete all the lines between two characters. for example I want to delete the first line all the way up to the } character host test019 { hardware ethernet... (10 Replies)
Discussion started by: ryanique
10 Replies

5. Shell Programming and Scripting

shell script question

Hi, The contents of my file is below: Name,Location,Degree,Gender,Awards Robert,Philadelphia,Accounting,Male,5 Jane,Chicago,Business,Female,2 Allan,New York,Engineering,Male,6 Tom,Detroit,Computer Science,Male,10 Nancy,Milwaukee,Engineering,Female,4 I want to add a "ID" in the 1st line... (2 Replies)
Discussion started by: xinoo
2 Replies

6. Shell Programming and Scripting

shell script question

I have script as following.. server_status= some command | grep "Total error: 0" if ; then echo " Server $(hostname) is Down" >>Result fi else echo " Server is OK on $(hostname)" >>Result the if command seems to be not working properly for some... (13 Replies)
Discussion started by: s_linux
13 Replies

7. Homework & Coursework Questions

Question on shell script

Hiiiiiiiiiiiii all, Please i want your help fast, the teacher gave us this assignment can u help me to write it? this is the question: Write a shell script to point all prime numbers from the fibonacci series of integer N? using Red hat Os Thanks all and waiting for ur answers... (1 Reply)
Discussion started by: moonlips
1 Replies

8. Homework & Coursework Questions

question on shell script

hiiiiiiiiiiiii,,I found an error on my following script but couldnt find it!!! Can you please help me as soon as possible?! echo "enter a number " read n i=0 first=0 second=1 result=0 prime="true" echo –n " $first $second " while do result=`expr $first + $second` first=$second... (10 Replies)
Discussion started by: moonlips
10 Replies

9. Homework & Coursework Questions

question in shell script

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: Write a Bourne shell script which: • Has one command line argument. • If the command line argument is a... (5 Replies)
Discussion started by: abood1190
5 Replies

10. Shell Programming and Scripting

Shell script question

Hi all, can you plz check whether the below code is correct & some inputs. I need to read the below file and process it. input : /home/ibm/var.txt urgent not urgent not needed. #!/usr/bin/ksh VAR=/home/ibm/var.txt if ] then (7 Replies)
Discussion started by: ramkumar15
7 Replies
libpgm(3)                                                    Library Functions Manual                                                    libpgm(3)

NAME
libpgm - functions to support portable graymap (PGM) programs SYNOPSIS
#include <pgm.h> void pgm_init( int *argcP, char *argv[] ); gray ** pgm_allocarray( int cols, int rows ); gray * pgm_allocrow( intcols ); void pgm_freearray( gray **grays, introws ); void pgm_freerow( gray *grayrow); void pgm_readpgminit( FILE *fp, int *colsP, int *rowsP, gray *maxvalP, int *formatP ); void pgm_readpgmrow( FILE *fp, gray *grayrow, int cols, gray maxval, int format ); gray ** pgm_readpgm( FILE *fp, int *colsP, int *rowsP, gray *maxvalP ); void pgm_writepgminit( FILE * fp , int cols, int rows, gray maxval, int forceplain ); void pgm_writepgmrow( FILE *fp, gray *grayrow, int cols, gray maxval, int forceplain ); void pgm_writepgm( FILE *fp, gray ** grays, int cols, int rows, gray maxval, int forceplain ); void pgm_writepgm( FILE *fp, gray **grays, int cols, int rows, gray maxval, int forceplain ); void pgm_nextimage( FILE *file, int * const eofP); void pgm_check( FILE * file, const enum pm_check_type check_type, const int format, const int cols, const int rows, const int maxval, enum pm_check_code * const retval); typedef ... gray; #define PGM_MAXMAXVAL ... #define PGM_OVERALLMAXVAL ... extern gray pgm_pbmmaxval; #define PGM_FORMAT ... #define RPGM_FORMAT ... #define PGM_TYPE PGM_FORMAT #define PGM_FORMAT_TYPE(format) ... DESCRIPTION
TYPES AND CONSTANTS Each gray should contain only the values between 0 and PGM_OVERALLMAXVAL. pgm_pbmmaxval is the maxval used when a PGM program reads a PBM file. Normally it is 1; however, for some programs, a larger value gives better results. PGM_OVERALLMAXVAL is the maximum value of a maxval in a PGM file. PGM_MAXMAXVAL is the maximum value of a maxval in a PGM file that is compatible with the PGM format as it existed before April 2000. It is also the maximum value of a maxval that results in the minimum pos- sible raster size for a particular image. I.e an image with a maxval higher than PGM_MAXMAXVAL cannot be read or generated by old PGM pro- cessing programs and requires more file space. PGM_FORMAT is the format code for a Plain PGM format image file. RPGM_FORMAT is the format code for a Raw PGM format image file. PGM_TYPE is the format type code for the PGM formats. PGM_FORMAT_TYPE is a macro that generates code to compute the format type code of a PBM or PGM format from the format code which is its argument. INITIALIZATION All PGM programs must call pgm_init() just after invocation, before they process their arguments. MEMORY MANAGEMENT pgm_allocarray() allocates an array of grays. pgm_allocrow() allocates a row of the given number of grays. pgm_freearray() frees the array allocated with pgm_allocarray() containing the given number of rows. pgm_freerow() frees a row of grays allocated with pgm_allocrow(). READING FILES If a function in this section is called on a PBM format file, it translates the PBM file into a PGM file on the fly and functions as if it were called on the equivalent PGM file. The format value returned by pgm_readpgminit() is, however, not translated. It represents the actual format of the PBM file. pgm_readpgminit() reads the header of a PGM file, returning all the information from the header and leaving the file positioned just after the header. pgm_readpgmrow() reads a row of grays into the grayrow array. format, cols, and maxval are the values returned by pgm_readpgminit(). pgm_readpgm() reads an entire PGM image into memory, returning the allocated array as its return value and returning the information from the header as rows, cols, and maxval. This function combines pgm_readpgminit(), pgm_allocarray(), and pgm_readpgmrow(). WRITING FILES pgm_writepgminit() writes the header for a PGM file and leaves it positioned just after the header. forceplain is a logical value that tells pgm_writepgminit() to write a header for a plain PGM format file, as opposed to a raw PGM format file. pgm_writepgmrow() writes the row grayrow to a PGM file. For meaningful results, cols, maxval, and forceplain must be the same as was used with pgm_writepgminit(). pgm_writepgm() write the header and all data for a PGM image. This function combines pgm_writepgminit() and pgm_writepgmrow(). MISCELLANEOUS pgm_nextimage() positions a PGM input file to the next image in it (so that a subsequent pgm_readpgminit() reads its header). pgm_nextimage() is analogous to pbm_nextimage(), but works on PGM and PBM files. pgm_check() checks for the common file integrity error where the file is the wrong size to contain all the image data. pgm_check() is analogous to pbm_check(), but works on PGM and PBM files. SEE ALSO
libpbm(3), libppm(3), libpnm(3) libpgm(3)
All times are GMT -4. The time now is 12:09 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy