Using GET, passing argument to bash


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Using GET, passing argument to bash
# 1  
Old 09-26-2009
Data Using GET, passing argument to bash

Hi guys!

So, I use GET ( Simple user agent using LWP library. ) on a remote text file that is then passed to bash and executed. However, I need to pass that bash script a single argument, and so far nothing that I have tried has worked, although I have learned quite a bit about input/output redirection, pipes, and everything else! I have shown below SOME of the man attempts:

Code:
GET domain.tld | bash -- parameter
GET domain.tld | bash parameter
GET domain.tld parameter | bash
GET domain.tld -- parameter | bash
bash < GET domain.tld

Any help for this particular issue would be great!
# 2  
Old 09-26-2009
Could you post an example of GET's output? What exactly you're trying to pass to bash?
If I understand correctly this one should do it:

Code:
GET domain.tld parameter | bash

# 3  
Old 09-26-2009
Doesn't matter what code you use as long as it wants an arg/param, and doesnt matter what you parse to it, for instance:

Code:
#!/usr/bin/bash

testFile=$1

if [[ -z "$testFile" ]]
then
    echo "No parameter specified."
else
    echo "Parameter specified, $testFile"
fi

Now on another remote server:

Code:
-bash-3.2$ GET domain.tld/test | bash
No parameter specified.

If you try adding anything as bash's args (aside from its standard args) it will tell you that particular file is not found (such as: bash -- arghere).

The above code, being simple in construction, should have any text passed to it.
# 4  
Old 09-26-2009
Code:
zsh-4.3.10[t]% cat s    
#!/usr/bin/bash

testFile=$1

if [[ -z "$testFile" ]]
then
    echo "No parameter specified."
else
    echo "Parameter specified, $testFile"
fi
zsh-4.3.10[t]% bash s x 
Parameter specified, x

In your case:

Code:
bash  <(GET ...) param1 [param2 ... n]


# 5  
Old 09-26-2009
This perhaps?
Code:
bash <(GET domain.tld parameter)

or
Code:
(GET domain.tld parameter)|bash

# 6  
Old 09-26-2009
radoulov - Thank you very very much, that worked perfectly! Now I need to go study more bash!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Passing a second argument

I am trying to pass a second argument like so: if ] then export ARG2=$2 else message "Second argument not specified: USAGE - $PROGRAM_NAME ARG1 ARG2" checkerror -e 2 -m "Please specify if it is a history or weekly (H or W) extract in the 2nd argument" fi however, it always goes... (4 Replies)
Discussion started by: MIA651
4 Replies

2. Shell Programming and Scripting

Argument passing

How to pass the alphabet character as a argument in case and in if block? ex: c=$1 if a-z ]] then echo "alphabet" case $1 in a-z) echo "the value is a alphabet" edit by bakunin: please use CODE-tags. We REALLY mean it. (9 Replies)
Discussion started by: Roozo
9 Replies

3. Shell Programming and Scripting

Help with passing argument

Hi, I have a script that is scheduled with cron and runs every night. The cron part looks like this: 00 20 * * 0,1,2,3,4,5,6 /usr/local/bin/BACKUP TBTARM HOT DELETE My issue is with the 3rd parameter. Somewhere in the script, i want to tell the script to delete some files if the 3rd... (7 Replies)
Discussion started by: dollypee
7 Replies

4. Shell Programming and Scripting

passing argument in script?

hi, I want to implement some function to perform following task if ; then $TEXT = "Data_0" else $TEXT = $1 fi if ; then $Lines = 45 else $Lines = $2 fi Kindly suggest, thanks (11 Replies)
Discussion started by: nrjrasaxena
11 Replies

5. Shell Programming and Scripting

passing an option as an argument!

Hi Folks I have got to the point where I can specify the arguments but how to pass an option is still mystery to me. Example: temp.csh a b c d set temp1 = $argv set temp2 = $argv set temp3 = $argv echo $temp1 a echo $temp2 b echo $temp3 c d I WANT: temp.csh a b c d -S 1 set temp1... (2 Replies)
Discussion started by: dixits
2 Replies

6. Programming

Passing argument to command in C

Hello all, New to C and I'm trying to write a program which can run a unix command. Would like to have the option of giving the user the ability to enter arguments e.g for "ls" be able to run "ls -l". I would appreciate any help. Thanks #include <stdio.h> #include <unistd.h> #include... (3 Replies)
Discussion started by: effizy
3 Replies

7. Shell Programming and Scripting

passing Argument

Hi All, i have script like below.. echo "1) first option" echo "" echo "2) second option" echo "" echo "*) please enter the correct option" read select case $select in 1) echo "first option selected" ;; 2) echo "second option selected" ;; *) echo "please enter the correct... (4 Replies)
Discussion started by: Shahul
4 Replies

8. Shell Programming and Scripting

Problem in argument passing

Hell all, i have a problem in argument passing. print() { a=$1 b=$2 c=$3 echo $a echo $b echo $c } x="1 2 3" y="4 5 6" z="7 8 9" print $x $y $z. (4 Replies)
Discussion started by: tsaravanan
4 Replies

9. Shell Programming and Scripting

Passing more than one argument in a function

Hi All, Calling a function with one argument and storing the return value in a shell script is as below:( so far I know) value="`fun_1 "argument1"`" Its working perfectly for me. Can u help me with passing more than one argument and storing the return value Thnaks in advance JS (1 Reply)
Discussion started by: jisha
1 Replies

10. Programming

Thread Argument Passing

#include <stdio.h> #include <pthread.h> #define NUM_THREADS 4 /* function to be executed by the new thread*/ void *PrintHello(void * threadid) { printf("\n %3d:Hello World!\n",threadid); pthread_exit(NULL); } int main(int argc, char * argv) { int *taskids; int... (2 Replies)
Discussion started by: narom
2 Replies
Login or Register to Ask a Question