So i have that script to which i'd like to pipe (rather than just regular arguments) some data from another virtual output command.
Simplified:
When i know how many args i expect, i can handle this simple by:
But how would i approach to get an unknown number of arguments?
Any ideas please?
EDIT
Oh yeah, given the asterix example, i expect some values to be strings with spaces, which should remain preserved.
Otherwise i'd already have tried:
Thank you in advance
---------- Post updated at 03:54 ---------- Previous update was at 03:48 ----------
Just tried, but i knew it wouldnt work:
NOTE: If i'd quote the ARRAY=ARGS statement, i'd get all vars on one line..
I am writing script in c shell and using this script to read the command line arguments, but it is not working. Pl. someone let me know what is the problem.
#!/bin/csh -f
if ($#argv <> 2) then
echo "you must give exactly two parameters"
else
set name1 = $argv
... (1 Reply)
I have to write a C program using sys call (read, no fread) to read from shell all the parameters, without know how many are them.
I tryed in some ways, but I have no success.
Any Idea?
Can I use read to read from stdin? (1 Reply)
Hi,
What is the maximum number of arguments that could be passed to zsh ?
To find out that I tried a simple script.
And the maximum number of arguments that could be passed turned out to be 23394
#! /bin/zsh
arg=1
i=1
subIndex=23000
while
do
arg=$arg" "$i
i=$(($i + 1))... (9 Replies)
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:
Your script must check for the correct number of arguments (one argument). If somebody tries to invoke the... (1 Reply)
I have trouble getting this logic to work
#!/bin/bash
function assign_var(){
while
do
read -p "$2 :" $3
done
}
assign_var '$IPADDRESS' ipaddress IPADDRESS
Basicly, i want to make sure that entry is made (i can add more sophisticated checks later), but the idea is to recycle... (11 Replies)
Hello,
I am trying to make a bash script that can pull data from a file and then change one part of said data.
I want to search by username and pull the full line. That way there is a way to replace just one part of that line then return it back to the file.
My Data is stored like:
... (1 Reply)
I am developing a script where 3 other scripts are included.
This is a graph related script.
COMPLETE IDEA:
-There are 3 different graph scripts. I would like to create a master graph with all 3 in one.
-User chooses the type of graph
-User is asked to enter the required auguments (... (7 Replies)
Hi,
I am having a bit of trouble writing this.
I have the script working if I only use 1 of these but it's not working the way i need it to.
Basically more above the script i may or may not have a 5th variable defined. if i do it does a process before getting to the rest of the script.... (2 Replies)
I need to declare a function, this function will contain a script, this script cannot be in a file but must be piped. and then, for the script to run, i need to pass arguments to it.
everything has to be on one line. so i'm basically looking for a one-liner
here's what i'm doing:
myfunc ()... (3 Replies)
suppose i have a perl script that is normally run this way:
./checkdisk.pl -H hostname -w 40 -c 80
but, for whatever reason, i cannot run the script directly as it should. But i can cat it through pipe. How can i pass the arguments "-H hostname -w 40 -c 80"?
so this is what i'm doing,... (6 Replies)
Discussion started by: SkySmart
6 Replies
LEARN ABOUT OSX
pipe
PIPE(2) BSD System Calls Manual PIPE(2)NAME
pipe -- create descriptor pair for interprocess communication
SYNOPSIS
#include <unistd.h>
int
pipe(int fildes[2]);
DESCRIPTION
The pipe() function creates a pipe (an object that allows unidirectional data flow) and allocates a pair of file descriptors. The first
descriptor connects to the read end of the pipe; the second connects to the write end.
Data written to fildes[1] appears on (i.e., can be read from) fildes[0]. This allows the output of one program to be sent to another pro-
gram: the source's standard output is set up to be the write end of the pipe; the sink's standard input is set up to be the read end of the
pipe. The pipe itself persists until all of its associated descriptors are closed.
A pipe whose read or write end has been closed is considered widowed. Writing on such a pipe causes the writing process to receive a SIGPIPE
signal. Widowing a pipe is the only way to deliver end-of-file to a reader: after the reader consumes any buffered data, reading a widowed
pipe returns a zero count.
The generation of the SIGPIPE signal can be suppressed using the F_SETNOSIGPIPE fcntl command.
RETURN VALUES
On successful creation of the pipe, zero is returned. Otherwise, a value of -1 is returned and the variable errno set to indicate the error.
ERRORS
The pipe() call will fail if:
[EFAULT] The fildes buffer is in an invalid area of the process's address space.
[EMFILE] Too many descriptors are active.
[ENFILE] The system file table is full.
SEE ALSO sh(1), fork(2), read(2), socketpair(2), fcntl(2), write(2)HISTORY
A pipe() function call appeared in Version 6 AT&T UNIX.
4th Berkeley Distribution February 17, 2011 4th Berkeley Distribution