Programming :: Bash: Repeat Commands Until A Condition Is Matched?

Mar 8, 2011

need to modify some scripts to repeat the commands in them until a variable returns a proper value. I need it to add some redundancy to some scripts i use to upload files to a remote server.This is an example of a portion of those scripts:

Code:
################## site UPLOAD ##################
site_login=$(curl -c $site_cookie -L -F user=$site_user -F pass=$site_password -F

[code]....

View 4 Replies


ADVERTISEMENT

Programming :: BASH Conditionals - Passing Condition As Variable ?

Sep 17, 2009

I'm trying to implement an assert function similar to:[url]

However, I'm having trouble with file existence testing when the file name has a space in it.

I have distilled the problem down to the following:

This code works as expected, printing 'yes' if '~/test file' exists, and no if not.

Code:

However, this code gives an error.

Code:

The error:

Code:

Which tells me that it is splitting ["~/test file"] into ["~/test] and [file"]. Why? Is there a way around this?

Note that if you simply use a file path without a space, both cases work perfectly. Is this a BASH bug possibly? I just can't understand why the first would work, but the second wouldn't.

View 8 Replies View Related

General :: Configure Using Arrow Key To Repeat Previous Shell Commands In Minix?

Jul 20, 2011

I am new to Minix. I'm so impressed by the speed of the system. It looks elegant, I like it. However, I have a question about the shell. In Linux, while using a shell, up and down arrow keys can be used to navigate through previously executed commands. On Minix with the sh shell, I can only get numbers printed out on the screen. I remember I chose a US-std keyboard when installing. Is there any way to use the arrow keys to navigate through previous commands on Minix?

View 1 Replies View Related

Programming :: Bash And Sed Or Awk Commands To Set Tabs?

Apr 25, 2010

want to set more text files. They have "tab" differently (3, 4, 6 or 5 characters space).I have to use "sed" or "awk" sette them in the same tab (for example five space haracters).

View 14 Replies View Related

Programming :: Where Are BASH Commands Stored

Feb 21, 2011

Where are the other BASH commands/exe stored? If the commands are part of the exe of BASH than ls would not be in a path, correct?

View 11 Replies View Related

Programming :: Awk Commands Inside Of A Bash Script ?

May 4, 2011

im pretty sure this is a remedial task for many of you but im having an issue with arrays from a shell script being accessed in an awk command. im pretty good with shell scripting but i am embarrassingly unfamiliar with awk. so here's the meat of the script...


Code:

I am trying to take an input file of ip addresses and corresponding netmasks and put it into a format to be loaded onto a juniper switch. the result should look something like this.. x.x.x.x/netmask using the cidr notation. no matter what subnet is provided though, /32 always gets appended to the end of the ip even when it should be /16, /24, etc... also, the cisco part works fine so that doesnt need any attention.

View 5 Replies View Related

Programming :: Combining Commands And Var's In Bash Shell Script?

Jan 5, 2011

I have a command which on the command line needs to look like this

rlam -if3 '!pvalue -H image1.jpg' > image2.jpg

Nevermind what rlam or pvalue do ... they are part of a program package I am using. The above command works on the command line, and also when written verbatim in a bash shell script.

My problem is: in the script I wish to replace image1.jpg with the content of a variable, e.g.

IM1=image1.jpg

How to I get the script to insert the value of $IM into the command when the pvalue part of it needs to be quoted?

View 1 Replies View Related

Programming :: Simple Bash Script Is Not Running All Of The Commands?

Jun 14, 2010

I am running a simple script that I copied from slug.ceca.utc.edu/docs/2009-3-26-linux-server-health.pdf and edited with the names and paths of my own servers. I don't know much about scripting (re: nothing) but I wanted to try and be efficient in my new role as a Linux Sys Admin. The script was saved to root's home directory and runs as part of root's crontab once a week. The script runs with no problem, but it doesn't actually seem to run all of the commands contained within. It skips some in the middle and the end and I don't know why. The script itself is this:

Code:
#!/in/bash
uname -a > /tmp/server.txt

[code]...

View 5 Replies View Related

Programming :: Can Bash Commands Be Converted To Assembly Like C Source Code?

Nov 30, 2010

I have read where C is first converted to Assembly before its final compilation to binary. Is there a way to do this with Bash commands? I would like the understanding that Assembly allows to Bash somehow.

View 14 Replies View Related

Programming :: Get The Strings That Matched Sub-expressions?

Jun 8, 2010

Using the regex.h functions, how do you:

1) get the matched strings?

2) get the strings that matched sub-expressions?

View 4 Replies View Related

Programming :: Awk - Substitution With Parts Of Matched Regular Expression Used?

Apr 30, 2011

I remember reading that using sed, you can do this with parentheses: s/abc(something)def/(something)else/g I can't find an explanation of how to do something like this with Awk. Say you have this in an HTML file, where (number) stands for a one or two-digit number:

<sup>(number)</sup>

And you want to change that to this:

<a name="(number)t" href="#(number)b"><sup>(number)</sup></a>

How would this be possible? Would you have to use sed?

View 4 Replies View Related

Programming :: Add A Character To The End Of A Line When A Certain Match Text Is Matched?

Nov 5, 2010

Is there any way to add a character to the end of a line when a certain match text is matched. I have a text file where any line that contacts text XYZ a z is placed at the end.

View 1 Replies View Related

Programming :: Shell To Remove Line Matched With Variable?

Jul 25, 2011

I'm using sed to remove certain line in a text file based on a match with 2 variables from input. Here is how it looks like in file

Philip S:Odds:45:343
Mike Junior:Odds:3:56

I prompt for 2 inputs in variable form which is compared to the first 2 fields of the above text (: seperated). So say i enter Philip S and Odds then it should delete the entire first line.

View 4 Replies View Related

Programming :: Suspend Pthreads Without Condition

Jun 29, 2010

I just started with Pthreads and don't really know much about it. I want to suspend pthreads but apparently, there is no such function as pthread_suspend. but I don't understand why we need both mutex and condition to suspend and resume a pthread. Is it possible to suspend and resume it without using conditions?

View 1 Replies View Related

Programming :: Awk: Swap Fields Given A Condition?

Oct 8, 2010

I have a file records as follows:

Jane pepe@pepe.biz
john@pepe.net John
Joe joe@willxyz.org

How can I get that always first field be given name and second one be the mail address?

I've tried

Code:

awk '$1 ~ /@/ { a=$1 ; $1=$2; $2=a; print }' file

But that doesn't worked

View 5 Replies View Related

Programming :: Iptables Script With For Condition?

Apr 28, 2010

i have a question regarding the use of a statement, like following, in a iptables script.

Code:
BLOCKMAC="/root/mac.blocked"
MACS=$(grep -Ev "^#" $BLOCKMAC)

[code]...

View 2 Replies View Related

Programming :: Update A Line Using AWK With Condition?

Jun 18, 2010

i have a host file called myhosts.txt as follow:

Quote:

10.20.3.9 host1
10.20.3.10 host2
10.20.3.11 host3

[code]...

In my script, i am using NSLOOKUP to get the ip address of a host that just rebooted and connected to my network (this part has been done).But now i want to check the myhosts.txt file if the host has the same or different IP address, if is different then myhosts.txt file must be updated with the new IP.i am using the following AWk command:

Quote:

awk '/host4/{$1=val}{print}' val=10.0.3.4 /tmp/myhosts.txt

it prints on screen fine and i see the host4's ip address gets replaced but the actual file does not get updated with the new IP. I might need to use gsub?

View 11 Replies View Related

Programming :: Use If Else Condition When Returns Empty Data?

Apr 27, 2010

Let say I would like to check /etc/profile whether defined umask 022

umaskcheck=$(What to defined here?)
if [ What to define here? ]
then

[code]....

View 2 Replies View Related

General :: Running Bash But Common Bash Commands Not Working?

Jul 17, 2010

below are the details of my system. I have bash as my current shell, some really common commands aren't working.

Do I need to do a re-installation of bash? Or how do I install a selection of bash commands which I need? (for example a subset of [URL])

Code:
root@sdptfw:~ # uname -a
Linux sdptfw.sdpt.co.za 2.4.36 #1 Tue Jul 22 13:13:24 GMT 2008 i686 i686 i386 GNU/Linux
root@sdptfw:~ # echo $SHELL$
/bin/bash$

[Code]....

View 13 Replies View Related

Programming :: Removing Left Recursion - Construct An AST From It By Executing A Piece Of Code For Every Nonterminal Matched?

Apr 7, 2011

I'm still a but confused about the standard way of removing it for left-associative operators: [URL] Especially about how to construct an AST from it by executing a peice of code for every nonterminal matched. And I'm still not totally convinced that it will be left-associative, I just barely understand it. Also, how would you remove left-recursion for something like this:

Code:
expr ::= expr "(" param_list ")"
| other stuff...?

View 8 Replies View Related

Programming :: Create Awk Sript For Generating Two Files From A File Checking A Condition ?

Mar 3, 2010

I have a csv file like, having HDR segment and multiple LIN01 segment in each line:like

Here i want to split file in two, one having LIN01 segment which have LR at end, and one which have LF at end in LIN01 segment.

Is it possible to created awk or shell script for this?

View 3 Replies View Related

Programming :: Sed To Output Block Of Text If Specified Text Is Matched?

Feb 13, 2010

I am trying to find sed command combination to print out the "start command" line, the id line and all lines between "details" and "stop command" only if "error" exists. Here's the original output (test.txt):

start command
id 1
kajsdlfjsalj

[code]...

View 3 Replies View Related

General :: SSH Connection From BASH Script Stops Further BASH Script Commands

Dec 3, 2010

What happens when the script executes is that the ssh connection works and parks me at the remote hosts's shell login. Therefore, the "firefox" command refuses to execute. I need to know how to make the "ssh" connection occur, stay open, and go into the background so that the rest of the script can execute.If I could also do this with the "firefox" line so that the entire term window could be closed would also be helpful.

View 3 Replies View Related

Fedora :: Some Bash Script Commands Won't Run

Aug 6, 2009

I'm setting up a scheduler to run some bash script commands but they won't run when I point them to a script file. If I change the cron to call

[code]...

If I run ./writeTimeToLog from the terminal - it, well, writes the time to the log file! I then use

[code]...

to test I can schedule this to run every minute just so I can see it working. the entry was a basic as I could make. It adds the cron successfully but never seems to update the file. Where would an error be put if one occurred.

View 2 Replies View Related

Ubuntu :: Embedded Commands In Bash?

Apr 7, 2010

I would like to be able to connect to a machine, list a directory, wait long enough for me to see the results then move on to the next machine.This is failing:

Code:
#!/bin/bash
while read line; do

[code]...

View 3 Replies View Related

General :: Running SQL Commands From Within Bash

Aug 1, 2010

I would be running SQL commands (UPDATE/SELECT) from within my bash script. I am completely new to this subject. Is MYSQL used for this purpose? Alternatively, what is sqlplus?

View 6 Replies View Related

CentOS 5 Server :: Can't Run Any Bash Commands

Dec 21, 2009

Our CentOS 5 server had a weird issue last Friday. We couldn't run any bash commands, such as ls, vi. It said that it could not find /bin/ls. The only commands we can run are internal commands, such as ps, cd. After we reboot the server, everything is back.

I don't know what's wrong with it. Does anyone give me a explanation?

View 2 Replies View Related

Fedora Security :: Bash Commands As Root

Mar 3, 2010

I need to launch a bash file in Linux from an unprivileged user session, file that will run bash commands as root. But I do not want to create an user with root privileges to do that.

View 10 Replies View Related

General :: Commands See Files, Bash Doesn't?

Sep 10, 2010

This is a really odd bug I can't seem to figure it out. Basically, commands like ls can see all the files in the current directory, however when I go to execute the file it will give errors like "file not found", even when it most obviously is. If you look at my command history in the screenshot, you can see I can ls into a directory and see it's contents. When I try to run the file, I get the "no such file or directory" error.

However, if I type simply 'vm', I can't use tab completion to complete the directory name, and my third command is me typing 'vm' and hitting tabtab, it lists a bunch of vmware specific tools instead of the subdirectory name. I can then ls and see my current directory contents, and it will list only the single subdirectory. However, then I tried to use the full filepath from root to run the file, still to no avail. If anyone has any insight,

View 2 Replies View Related

General :: Bash - Passing Commands To CLI Using A Script

Jul 31, 2011

is there any way I can pass commands to the CLI of a tool directly?

I would like to script some actions, for example:

./OpenBTS < "tmsis"

I do not need to retrieve the results (I watch it in the log file). how I could realize that? There is now way to do this using command line parameters, at least not that I found out. So it looks like I have to figure out sth myself. Maybe I could automate screen in a way to detect the prompt and "paste" my command there. Are there tools for this on Linux?

View 3 Replies View Related







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