General :: Understanding How Pipe Works In Bash

Aug 21, 2010

I don't quite understand how pipes work in bash. I know that it takes an output from one command as the input in another command. What an output is I can get because it's what the command prints out to the screen. But how do I know what input a command will take? Here is an example I thought would work:

Which gem | rm
Unfortunately it didn't.
Which gem prints out "/usr/bin/gem" so that must be the output right? I thought that was given to rm so it would be "rm /usr/bin/gem" but I was wrong. How do I know what input a command takes?

View 4 Replies


ADVERTISEMENT

General :: Flow Control In Bash Pipe?

Jul 25, 2010

Two processes are communicating through a pipe: A | B. A is writing data faster than B is reading it in. Is there any way to have A limit its writing rate to match B's reading rate?

AFAIK the pipe will get full, and will make A's writing block, waiting for B to read in more data. But is there a way to limit A's writing rate before the pipe fills up? (In a way it's like having a pipe with a really small capacity, but as far as I know pipe capacity is a constant compiled into the kernel.)

Code:

EXAMPLE FOR CLARIFICATION

Right now the command is printing out the following in 1-second intervals:

But with flow control it should print out (again in 1-second intervals):

...since "date" would block on the writing loop due to the slow reading loop.

View 4 Replies View Related

Programming :: BASH: Get PID Of First Command In Pipe

Aug 11, 2010

I understand that $! is the PID of a command. For example:

Code: #!/bin/bash
myprogram &
echo "PID of myprogram is $!"

I'd like to send the output of "myprogram" to both console and to a log file using the "tee" command but I also want to store the PID of "myprogam". Something like this:

Code: #!/bin/bash
myprogram | tee ./logfile &
echo "PID of myprogram is $!"

The problem is that $! is now the PID of "tee" rather than the PID of "myprogram".

View 3 Replies View Related

Ubuntu :: Pipe Bash Script To Zenity's Progress Feature?

Feb 22, 2010

Example from zenity:

Code:
#!/bin/sh
(

[code].....

View 1 Replies View Related

CentOS 5 :: Bash Script Under Cron Produces Broken Pipe

Apr 20, 2011

I have script which does file locking via flock and then writing it's pid into that file. It perfectly works being run by hand in terminal, running under cron on Debian, but somehow fails being run under cron on Centos 5.6. Script part and straced outputs are below.

bash code:

#setting lock
mylog "setting lockfile $LOCKFILE"
exec 200<> $LOCKFILE

[code]....

View 4 Replies View Related

Server :: Bash Scripting Sending Write Error - Broken Pipe

Apr 19, 2010

I move a page from a server in SuSe to Debian and this script was working well but when I move the page to a Debian base server it is sending in the logs the following message:

cat: write error: Broken pipe, referer: [URL]

The cgi does the following, read a db file plain text that repeat each 15 lines an information where to look the seraching info. if it is there sends to the output the 15 lines block. but it was not sending errors in suse distro, does anybody knows why the cat's line are sending "cat: write error: Broken pipe," if I am not writing or making a pipe with ">" to none file.

View 8 Replies View Related

General :: Bash Script Only Works When Manually Running?

Oct 8, 2010

I have a PGP script that for whatever reason if I let linux's cron run it automatically, it sends out the final email with attachment with a blank file. If I come in and run in manually everything works fine and the file is populated in the file. So the only real difference is that i'm running it manually through cron, rather than letting cron run it at a set time.Below is a sumary of my script.

Code:
#! /bin/bash
#PGP Decryption Bash Script

[code]...

View 6 Replies View Related

General :: Bash Script Works In Terminal But Not In Cron?

Feb 17, 2011

I'm really running into a wall trying to figure this out. I have a Bash script and narrowed down the one command that doesn't seem to work via cron and it's my pgp decrypting line. Works fine if I run the command via terminal but if I run it via cron it doesn't output anything.crontab -e shows the cronjob and it runs, creates the log file with no output. Is there maybe something I need to run as well? Permissions look set, unless the cron is running as a different user(was under the assumption if it showed up under crontab while logged into that user, then it would run as that user.

View 14 Replies View Related

Programming :: Handle A Broken Pipe Exception (SIGPIPE) In FIFO Pipe?

Mar 2, 2011

I've written a simple server in linux used fork to create a FIFO pipe.The server create two FIFO pipe.One for server read data from client and write data to client.Then another pipe for client read data from server and write data to server.When the server read data from a client used server-pipe and then write data to client.But ,if the client no read open the pipe,the server side write will be crashed because of a broken-pipe SIGPIPE. How to check whether the read side is opened?Or,how to catch the SIGPIPE,and then my server will still execute on,not crashed!!

View 5 Replies View Related

Networking :: PING - Pipe 2 Versus Pipe 3

Apr 10, 2009

I'm doing ping between 2 RH servers through a VPN site2site tunnel and in some times I got in the result pipe 2 and another pipe 3 as I mark it in blue color below.

e.g.

64 bytes from 192.168.1.10: icmp_seq=0 ttl=128 time=0.229 ms
64 bytes from 192.168.1.10: icmp_seq=1 ttl=128 time=0.287 ms
64 bytes from 192.168.1.10: icmp_seq=2 ttl=128 time=0.278 ms

[code]....

What's the difference between pipe 2 and pipe 3 and what's the meaning of it?

View 1 Replies View Related

General :: DD Imaging Of Builds Better Understanding

Nov 12, 2010

I am learning how to use DD for creating images across networks and locally but needed some clarification.
1 - When creating an image, I noticed that there is no verbose to show you the progress, How can I accomplish this?

2 - When I run this on a 8G usbstick it takes a long time to image. How can I speed up this process?
PHP Code:
dd if=/dev/sdb of=/home/test/images/image.dd

3 - When an image is restored like
PHP Code:
dd if=/home/test/images/image.dd of=/dev/sdb
will that give me a working bootable usbstick? For example if I imaged a working usbstick with Ubuntu on it using DD and restored it like the example above on a different usbstick, will this give me a booting new usbstick? I hope that came across ok?

View 1 Replies View Related

General :: Finding An Appropriate Distro And Understanding Setup?

Aug 11, 2010

I'm trying to set up a machine to "drive" a piece of equipment (a metal plate embosser [kind of like a daisywheel printer for credit card sized pieces of metal], FWIW). What I ideally want is a linux distro that I can boot from CD (I think the term is Live CD?), log itself in as a user and display only a console. It needs to be able to support windows fileshares and python.

Essentially it needs to boot, connect to a single fileshare on a Win2k8 machine, and be able to execute a couple of scripts that will output to a serial port. One of them will be more or less the following:

wget http://WEBSITE/?<parameter passed to script> --quiet --output-document=<name of serial port>

The other is a somewhat more complicated Python script that processes a CSV spreadsheet and produces data for the machine.

View 3 Replies View Related

General :: Understanding Md5 Password Placement In Grub?

Jul 13, 2011

My grub file looks like this:-

# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file

[code]...

View 4 Replies View Related

General :: Understanding Ubuntu User / Group Permissions

May 20, 2010

I'm beginning to deal with more than one user on my system (it's a VPS serving some sites) and I need to make sure I understand how group permissions work. I have an account named "admin" .. it's basically the primary account that is used for serving most of the sites that I control myself. Now, I added a second account named "Ville" as one of my users wants to be able to administer that site. So, I can do this the easy way and just chown their domains folder under the ville user, they have permission to do whatever they need be and so forth. However, let's say I want to also give the admin user access to the files (modifying and all) .. how can I put both users into the same group and give them both permission?

I've tried doing:
sudo usermod -a -G admin ville
To add the ville into the admin group, but ville still cannot edit files by admin. Permissions for the primary directory for the ville user are read/write for both owner and group, and the current group for the files is admin:admin ..
But ville still can't write into the directory. So, what should I be doing here to get this right and secure at the same time?

View 1 Replies View Related

General :: Compiling Programs - Understanding Concept Of Makefile2

Jan 13, 2011

# Filename: makefile2
# Usage: make-f makefile2
# Description: Maintains all the dependencies between modules using the
# Agenda1.

CC=g++
CFLAGS=-c -Wall
LDFLAGS=
SOURCE_MODULES=main.cpp factorial.cpp hello.cpp
OBJECT_MODULES=$(SOURCE_MODULES:.cpp=.o)
EXECUTABLE=programa1
all: $(OBJECT_MODULES) $(EXECUTABLE)
$(EXECUTABLE): $(OBJECT_MODULES)
$(CC) $(LDFLAGS) $^ -o $@
.o: .cpp
$(CC) $(CFLAGS) $< -o $@

I am suppose to explain the dependencies that exist and each of the following lines of makefile. Lists orders to be executed as a result of running the make utility on it.

View 3 Replies View Related

General :: Lack Basic Understanding Of Permissions (Apache)

Apr 8, 2010

I am very new to linux. The first time i ran a linux machine was one Saturday. Anyway I am trying to set up an apache web server, all I want to do is play around with html and post it on my unbuntu server so it is available to the internet. I am also trying to install samba but I am having trouble with that so for now I am using winscp. Ok, so I made a folder in my home directory for webstuff, and set up apache to look in that folder.

mkdir /home/username/webstuff
I put my index.html file into the /webstuff folder.
But when I go to my website, it says 403 error unable to access "/"

Did I make the folder in the right place? I do not want people being able to access my / folder so maby I made the web stuff folder in the wrong place? Also I thought I would just put my inded.html file inside of the default one apache gives you, but when I tried to transfer index.html it said permission denied. How to set up permissions so I can use apache and transfer my html files from my remote desktop to my server would be great!

View 7 Replies View Related

General :: Understanding Idle/Inactive Sessions And Whether Or Not Someone Is Logged In?

Jan 5, 2011

I'm trying to understand if anyone is left on a server. Basically I manage a simple linux server remotely used by 3-4 individuals. I can never tell if someone is actually on or not using w/who.What I'm seeing is some people having what appears to be inactive/lost VNC sessions. I don't understand idle fully, but I do believe a program (without user interaction) can clear idle back to 0, correct?Anyway, I'm asking because every now and then I need to reboot the server, and I do not want to interrupt any program working on calculations or waiting on having the data saved.

Code:
me@matrix:~> w
06:59:54 up 170 days, 9:13, 16 users, load average: 0.52, 0.16, 0.06

[code]....

View 1 Replies View Related

Programming :: Cmd Works In Bash, Not Crontab?

Jul 16, 2010

I want to write the date & time and a text string to a file from crontab.The following line works fine in the CL:echo $(/bin/date +"%F %T")" Some text" >> /home/me/foo.txtI installed in crontab and no text appears in the file that it is redirected to.The crontab entry looks like:* * * * * echo $(/bin/date +"%F %T")" Some text" >> /home/me/foo.txtTried a version to just write to stdout....* * * * * echo $(/bin/date +"%F %T")" Some text"No date, time or text appears at the command line

View 5 Replies View Related

Ubuntu :: Bash Script Works Partially In Cron?

Sep 24, 2010

I have a script that pops up a jpg file several times a day as a reminder. The script is called up by crontab and it works perfectly.The issue is that I want the script to also perform a system "beep" in addition to popping up the jpg file. When I test it on the command line everything works but when I run it in cron the jpg file pops up but the beep doesn't beep. I'm thinking the problem is in the "echo -e \a" part. I must be missing something.Here is my script:

#!/bin/bash
echo -e \a
sleep01; echo -e \a

[code]....

View 8 Replies View Related

Programming :: BASH - Works On The Command Line, Hangs As A Script?

Jul 16, 2010

I'm writing a Bash script to take IPTC keywords from a text file and write them, via Exiv2, to several (first batch is 100) JPEG files in a single directory. The script has one while loop inside another while loop, both terminated, but I'm pretty sure that's not my problem. I think it's how I'm incrementing the "counter" variable, although it could also be the method of parsing the text lines from the file (using cut with delimiters that have worked fine in simpler scripts).

Here's the code as I've worked it up to this point.

Code:

And yes, "keywords" checks out in Crimson Editor, Emacs GUI and nano as an ASCII file with UNIX line endings. No issues on that score.

Feeding each line consecutively into a terminal (excepting the exiv2 command) works fine: each variable echoes with the part of the text line used as a variable value as it should, even when the b variable is incremented the quick&dirty way (up arrow three commands and hit enter).

Running the above script in eval mode (sh -x) stalls after setting the b variable to one and reading in the first line of text. I'd like to know why. I'd also like some advice on another reliable method of parsing the read-in lines.

View 14 Replies View Related

General :: Get A General Understanding Put Simply?

Apr 3, 2010

Im trying to get a general understanding put simply.

View 6 Replies View Related

Programming :: Command Line Works - Won't Work From Inside Bash Script

Feb 16, 2011

Writing script to create backup of file by adding datetime to file name. Basically test for file presence if there, cp with datetime then rm original cp works fine from command line but get cannot stat `full path to file': No such file or directory

Code:

Here are the errors: cp: cannot stat `~/html/CVP_dadamail/.dada_files/.logs/errors.txt': No such file or directory rm: cannot remove `...': No such file or directory

The for statement is a placeholder as I have same file to backup out of several directories. using "bash -x scriptname" -OR- inserting echos, I can see I've constructed the strings properly. Believing it might be related to the hidden directories, I tried setting the shopt "glob" options to no avail.

Ultimately I'll add the other directories to the for loop and then run this from a cron job, so if you see potential pitfalls knowing I'm headed in that direction...believe construct would be

Code:

View 4 Replies View Related

General :: Can't Scp A Named Pipe?

Aug 2, 2011

I am trying to encrypt a file on-the-fly, redirecting the output to a named pipe [fifo]. I SSH into my server and run the command:mcrypt -k key < file > named_pipethen from my laptop I try to scp it:$ scp me@server:~/dir/named_pipe d it says scp:users/home/me/dir/named_pipe: not a regular file

View 1 Replies View Related

General :: Keyboard Won't Pipe?

Dec 23, 2010

I'm on the command line, as the install for the proprietary ATI driver has failed. I'm following the instructions for troubleshooting here but the pipe "|" key is not working - a tilda "~" shows up when I press it.I'm wondering if this is because of the keyboard being set as UK instead of US? I did have to change this setting at the graphical login initally, whether from choosing this setting by mistake or the installer choosing it automatically when I chose English UK for the language.

View 3 Replies View Related

Programming :: Bash Script For Automatic Viewport Changing And Other WM Stuff (works With Compiz)?

Oct 18, 2010

I had to make for work a collectd based network monitoring system which displays data for each server in a fullscreen conky on different compiz viewports. I have to switch viewports automatically when the machine isn't operated (sorta screensaver) and also if i had to call attention in the case something bad happens, autoswitching should stop and the relevant viewport be showed up.This requires an interface to talk dynamically to the WM, which i've implemented in bash with support of the widely available "wmctrl" program.

Code:
http://paste2.org/p/1177045
Code:

[code]...

View 8 Replies View Related

General :: Kill A Process Using Pipe?

Apr 22, 2010

We want to kill a process provided that only process name is given and we are to first find out the process id and then kill the process. Yes, in one go! That is, using pipe.

So, I tried this (the bold text):

[Code]...

View 17 Replies View Related

General :: Trying To Use Pipe Or Awk To Work With MPlayer

Feb 11, 2010

I have a text file containing the URL I wanted for mplayer to play. Currently, I play those in commend line using the following steps:
1)cat playlist
2)use mouse to highlight the link
3)type: mplayer then click both left/right mouse button

I was hoping if I can do this in comment line without mouse. I've tried the following without luck. (assume there's only 1 address in the text file)
1) cat playlist |mplayer
2) cat playlist |awk '{print $1}'| mplayer

View 4 Replies View Related

General :: Monitor Interprocess Pipe Traffic?

Dec 14, 2010

I have two Linux processes communicating via a nameless pipe. How can monitor the traffic in the pipe? How can I inject data into the pipe? I have root access and know the pipe inode.

View 2 Replies View Related

General :: Read File And Pipe To Grep

May 26, 2011

I'm storing a list of strings in a file and would like to read the file and pipe each line returned to grep which in turn searches a directory for files containing the string.However this is not returning any output.

View 2 Replies View Related

General :: PIPE Symbol Not Recognized In Script?

Aug 9, 2011

this is the simple backup script which i used to take backup the databases of my clients

Code:
#!/bin/bash
date=`date +%d-%m-%Y_%H.%M.%S`

[code]....

View 6 Replies View Related







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