Programming :: Shell Script For Adding A Statement In A File After A Particular Statement?

Jun 28, 2010

We are building our C++ project in Kdevelop IDE. Every time we run "Run Configure" from the "Build" menu, a file named "libtool" gets automatically generated. This file contains a statement as "ECHO="echo"".f we run "Automake", without modifying the "libtool" the system hangs and theputer needs to be restarted.Therefore every time we run "Run Configure" we need to include the line "echo="echo"" below the statement "ECHO="echo"" manually.I think a script can be written which does the above on its own.I am not a shell script programmer, I know the good tutorials for shell scripts are available on the net, but learning scripting only for this task would be time-consuming and painful.

View 4 Replies


ADVERTISEMENT

Programming :: Perl Switch Statement Throwing Error Like Bad Case Statement (invalid Case Value)?

Oct 6, 2010

I've written a simple perl code to learn switches in perl.My code is pasted below,

#!/usr/bin/perl
$opt = 1;
switch($opt) {

[code]...

View 3 Replies View Related

Programming :: Ignore Case In If Statement Shell Scripting

Feb 3, 2010

How do i make my strings case-insensitive while comparing them with an if statement?

View 2 Replies View Related

Programming :: Bash - Statement To Check If A File Exists Or Not?

Oct 6, 2010

This script that I found online does the job it promises. it does convert the files to mp3 without an issue. What I need to include now is an if statement that says If $file.mp3 exists then delete $file.wav

Code:
#!/bin/sh
# name of this script: wav2mp3.sh
# wav to mp3
# Credit to the script creator (Nikesh Jauhari):

[Code]...

After that I'm stumped as to how to do the if statement

View 14 Replies View Related

Programming :: Write An If Statement For The First Line Of A Text File Bash?

Feb 15, 2011

At the moment I got my md5sum checking working which I write to a text file and see below.

If the md5sum works it will write the output to check2.md5 test.txt: OK

If the md5sum fails it will write test.txt: FAILED

How do I write if statement to check the output whether or not the md5sum failed or not ?

check1="/home/ops/Desktop/test1/check1.md5"
check2="/home/ops/Desktop/test1/check2.md5"
cd /home/ops/Desktop/test1
md5sum test.txt > $check1

[Code]....

View 2 Replies View Related

General :: Script (Case & IF Statement Syntax) - Easy To Answer If Know Shell Scripting

May 6, 2011

Im a bit stuck with a simple script that im practicing with... im trying to get my head around some simple scripting. Basically i want to write a script that will work as below: It will ask the user to enter their userid. If its correct it will say 'Correct' If its the wrong id (But the ID exists in /etc/passwd) then it will say 'incorrect' If its not a valid userid it will say 'doesnt exist'. What i have so far is:

[Code]...

# If the user enters their own userid they will get a comment saying 'correct' $LOGNAME) echo "Correct";;

# If they enter another users ID (That exists in the /etc/passwd), then they get a message to say 'incorrect userid used'. Im not sure what i need to do here to get it to check the /etc/passwd to see if the input exists in there.... im guessing some kind of simple 'if' statement to say ---- "if 'input' exists in /etc/passwd then echo "incorrect userid used"

# If its entered incorrectly and not a valid ID then they will get this comment. Again, im guessing this part would be similar to te above option..... *) echo "not a valid ID";;

Ive managed to work out how the basic Case staements work, but to add a conditional statement based on the input, i just cant figure out. I have tried looking on google, and found some help but it doesnt really explain how i check the input against the /etc/passwd.

View 17 Replies View Related

Programming :: Script With Variable In If Statement?

Jul 9, 2010

I am trying to create a script to be used on RHEL server. If I replace the $t with a number, the script works. If I try add a variable or the $1, the script doesn?t work (returns all processes even if less than the $t value). I thought that it may be treating it as a literal, but I wasn?t sure of the conversion.

t=$1
echo $t
lcnt=`ps -eo pid,ppid,rss,vsize,pcpu,pmem,cmd -ww --sort=pid | awk '{if ($6 > $t) print

[code]...

View 2 Replies View Related

Programming :: Using If Then Statement Directly In Bash

Aug 12, 2009

When you use an if statement directly in bash you have to put the ";" at the end or not? or am I mixing it with the for loop? I am reading advance bash scripting and it shows the if - then statements without ";" so I need a little clarification here.

View 2 Replies View Related

Programming :: Put All The HTML In A Print Statement?

Sep 14, 2010

I have a site which will have, for example, a login system where people have to enter their usernames and passwords, depending on which they'll be let in to the site. So, in code, I've got a line like:

if ($_POST['password'] == $password) {
then do whatever
}
else { print "Wrong password" ; )

My problem is, this "Wrong password" printing is just a solitary line, not keeping with the colours and style of the site, and it looks very bad. I want to ideally, output some HTML, which will have a picture, and print the "Wrong password" in the font and colours I desire. Do I have to put all the HTML in a print statement, and then deal with the nightmare of escaping all the quote marks in it with a ""? Or is there a cleaner method to the whole thing? Maybe something like this -

if ($_POST['password'] == $password) {
then do whatever
}

[code]....

View 4 Replies View Related

Programming :: Code Sql Statement For Use In PHP Script

Sep 21, 2010

I'm trying to code a sql statement for use in a PHP script.I'm looking to find the number of matching records in two tables and display them.How would you write that statement.I've tried using count a few ways, but no cigar.

View 2 Replies View Related

Programming :: BASH - Regex In A Case Statement?

Jun 9, 2010

the following works and BASH doesn't complain, but VIM highlights the closing square bracket is if it sees a syntax error. Is there a better way to express regex in a case statement or is this an issue with VIM?

Code:
#!/bin/bash
case $1 in

[code]...

View 3 Replies View Related

Programming :: Escape '*' In Case Statement Bash

Jan 23, 2010

Does it possible to escape * in the case statement

Code:

View 2 Replies View Related

Programming :: Run SQL Update Statement In A For Loop In Bash?

Jun 7, 2010

The script that Iam trying to write is running a for loop and reading line by line from a text file. inside this for loop i would like to execute update SQL statement .

a pesudo code is
Quote:
`$ISQL -U $username -P $Password -D $Dbname -I $INTERFACE <<QRY
for id in $idlist #idlist iam reading from a file

[code]...

View 8 Replies View Related

Programming :: PHP / MySQL Statement - Query Result

Jan 29, 2011

It is under PHP/MySQL
$queryresult = $conn->query("INSERT INTO normalrequests VALUES($finalkey, 1234, 5678, FALSE)");
It is connected to the database successfully but I feel there is something wrong with the statement up there.

View 6 Replies View Related

Programming :: Case Statement Passing Multiple Arguments?

Aug 7, 2010

I've started dabbling with the case statement in order to pass some option's arguments into variables. I do not think I am doing this right.

Code:

usage() {
echo "Usage: $0 [-z|--snooze] [-c|--channel] [-p|--playlist]
[-m|--message] [-v|--mpcvolume]"

[code]....

As you can see, I want to pass arguments depending on the option(s) chosen by the user; ie. --snooze, or --channel. By default, if no options are chosen, I'll display a usage message; though in the future I'll provide some sane defaults. I'd like to create a case statement to handle passing arguments to any number of options; something like:

Code:

wakethehellup.sh --snooze 20 --message 'wake up!'

and for the other arguments, it would have a default set. The case statement I provided fails with a syntax error "syntax error near unexpected token `$2'" near the '--snooze' in the statement, so I take it you can't pass a parameter in this way; but I'm confused as to how I'm supposed to pass different parameters to different options without the options being confused as parameters.

View 2 Replies View Related

Programming :: If Statement Regex Match For White Spaces?

Apr 8, 2011

I want to match for this string:

Code:

Content-Transfer-Encoding:[:space:]base64
Content-Disposition:[:space:]attachment;[:space:]filename="%variable%"

Both lines are new lines, so they won't be inline. Other than that, they are all constants, I want this regex match to be an if statement rather than returning match string. so if the $content variable contains some string that matches:

Code:

if `sed "//p"` ;

View 4 Replies View Related

Programming :: Scanner - Completely Ignore The Kbd.nextLine Statement

Nov 12, 2010

This is what I have

Code:

When I run the program it will print

Quote:

rather than

Quote:

And completely ignore the kbd.nextLine statement.

However, when I write next instead of nextLine, it works.

View 3 Replies View Related

Programming :: UnixODBC - Commit After Freeing A Statement Handle?

Feb 16, 2011

A question of ODBC correctness - maybe someone knows.

Code:
// statement handle is sth, connection handle is dbch
SQLExecDirect(sth, ...);
// ... bind var, fetch results ...
SQLFreeHandle(SQL_HANDLE_STMT, sth); // free statement handle
SQLEndTran(SQLHANDLE_DBC, dbch, SQL_COMMIT);
(error checking removed for clarity).

To my mind this seems wrong - surely the statement handle should be free'd only after the commit is done? Or maybe not. I theorize about the ODBC library like this: a whole set of statements can be created, run, executed in one transaction (which is held at the connection level), and only after all that is a commit/rollback done. So maybe it's OK. Even so it still feels weird. What is written above works, but there are rare and very difficult to replicate problems with this code, and I wonder if a premature free might be the cause...?

View 2 Replies View Related

Programming :: String Comparison - Get Regular Expression To Work In If / Else Statement?

Jun 29, 2010

how do I get this regular expression to work in an if/else statement? This is just a little script for learning BASH. don't be too harsh.

This script will test if a certain number of files with 1-4 in their filename exist and print their filename. An error message will be printed if not.

#
for i in `ls file[1-9]`
do
if [[ "$i" == *1-4 ]] ; then
echo "This file, $i, ends in a number between 1-4"
else
echo "Error, this file, $i, does not end with a number between 1-4"
fi
done

I get this error. ./file_test.sh: 13: [[: not found

View 2 Replies View Related

Programming :: Gawk Statement To Match Range Of Filed For String?

Jul 30, 2010

adf 32 324 100 100 24 234I want a gawk statement to match the above line if lets sayand field between 4 and 6 == 100.

View 2 Replies View Related

Programming :: Regular Expression Doesnt Work In An Elsif Statement?

Feb 3, 2010

I was doing an exercise on Learning Perl, 3rd edition. (exercise chapter 10 btw) The problem asks to create a program that generates a random number and asks the user to guess. It should tell the user if the guess is lower or higher and exit if the user types either exit or quit. My code is the following:

Code:
#! /usr/bin/perl
$correct = int(1+rand 100);

[code]....

View 2 Replies View Related

Software :: Shell Script Using An If Statement And "wall"?

Apr 17, 2011

made a simple script called "msg" to make it simpler to use the "wall" command, but it is giving me some issues. The problem is more cosmetic than performance, but it's annoying.OS:Ubuntu 10.10 Text Editor: Nano (Probably not important, but hey...)Here's what I got:

Code:
#!/bin/bash
# Changes color to yellow

[code]...

View 4 Replies View Related

Programming :: If Statement Pattern Search / End Of Pattern Special Character?

Apr 29, 2010

I have to enhance the behaviour of a backup script written in perl. I don't need to change it, what I need to do is to create a bash script that does some checks like file name and file size, execute the backup script then check if the backup files match the original files.Here's how I try to do it:

- read the files from the original files folder
- store them in an array
- search in the array the files that have a specific file extension
- store the file names that match the search pattern (I know the backup script skips some files so I can hardcode the search pattern)
- run the backup script
- read the files from the backup folder
- store them in an array
- compare the original files name and size stored in an array with those from the backup folder
- send a report email

View 3 Replies View Related

General :: Scripting - Feed An Input File Into An If Statement Line-by-line

Dec 23, 2009

I am trying to write a script that takes an input file ($FileName) and an intermediate file ($FileName.info) and removes lines from $FileName if the value in $2 of $FileName.info is <75.

I can't figure out how to feed only one line of the .info file to the if statement at a time so that it will perceive it as an integer instead of a list.

The error I am getting now is ./script.sh: line 6: [: : integer expression expected

Sample input $FileName

Code:

Code:

Code:

Script so far:

Code:

View 10 Replies View Related

Programming :: Is The "./" Statement Just A Throwback

Mar 5, 2011

If I'm in a directory and I want to move into the next directory I just type it in raw without the relative ./ All I use is cd "next directory" enter. So my point is that I can not find a purpose for the "./" statement other than to state it on paper ;or the like as , ./directory/directory (from whatever current directory) I was in. Is the "./" statement for an older version of BASH?

View 14 Replies View Related

Ubuntu :: How To Create Path Statement

Aug 7, 2011

I have multiple drives and software that defaults to my primary drive. I want to change preferences to use my second drive.This is the current path "/home/guy/dvdrip-data" my second drive is named "2Internal".How do I properly format the path statement to use the second drive?

View 7 Replies View Related

Ubuntu :: Syntax Error On Done Statement

Nov 28, 2010

I have returned the below mentioned lines of code however I am receiving error "Syntax Error On Done Statement".

while:
do
clear
echo "-------------------------------------------------------------------"
echo "Main Menu"
echo "-------------------------------------------------------------------"
echo "[1] Today's Date"
echo "[2] Show files in the current Directory"
read yourch
case $yourch in

1) echo "Today is `date`,press a key ........";read;;
2) echo ls -l;read;;
*) echo "Select the yourch as 1 or 2";

View 3 Replies View Related

General :: Cd Inside If Than Statement After Fi Back To Old Dir

Jul 12, 2010

the script below prints the pwd of where I want to be. after the fi it puts me back at the original dir. just writing these scripts to understand what's going on.

#! /bin/bash
if
[ -d mydir ]
then
cd mydir/ && pwd
fi

View 4 Replies View Related

General :: If Statement With Multiple Tasks?

Feb 2, 2011

I want to have an if statement that does multiple things:

Code:

if [....] ; then
1=...
2=...

[code]....

View 3 Replies View Related

Debian :: Find & Modify Path Statement

Jul 19, 2011

I am running Debian Squeeze, 64-bit.I would like to try my hand at bash scripting. So at the author's suggestion (first chapter of Chris F. A. Johnson, Pro Bash Scripting from apress) I created a /bin directory in my home directory. So now I would like to modify my PATH statement so that when I run a script from my bin directory my shell will find it.I did that. He then says that I should add this to ".bash_profile, .bashrc, or .profile depending on how bash is invoked." The find command is unable to locate any of these files. So I searched the forum, found the link above and tried to follow that. No luck so I assume that how Debian handles PATH statements has changed since that post?

I also have checked the wiki and worked Google as hard as I know how to do.Very simply where the heck is my PATH statement and how do I modify it?

View 4 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved