The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Need to run the script by argument passing asirohi Shell Programming and Scripting 3 08-21-2009 11:15 AM
Passing non Awk Argument in Awk saifurshaon Shell Programming and Scripting 1 03-19-2009 06:57 AM
passing Argument Shahul Shell Programming and Scripting 4 11-13-2008 08:50 AM
Problem in argument passing tsaravanan Shell Programming and Scripting 4 09-23-2008 08:53 AM
passing argument into awk prkfriryce Shell Programming and Scripting 4 02-01-2007 04:44 PM

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 09-26-2009
Rhije Rhije is offline
Registered User
  
 

Join Date: Dec 2008
Posts: 103
Unhappy 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 (permalink)  
Old 09-26-2009
radoulov's Avatar
radoulov radoulov is offline Forum Staff  
addict
  
 

Join Date: Jan 2007
Location: Варна, България / Milano, Italia
Posts: 2,854
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 (permalink)  
Old 09-26-2009
Rhije Rhije is offline
Registered User
  
 

Join Date: Dec 2008
Posts: 103
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 (permalink)  
Old 09-26-2009
radoulov's Avatar
radoulov radoulov is offline Forum Staff  
addict
  
 

Join Date: Jan 2007
Location: Варна, България / Milano, Italia
Posts: 2,854
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 (permalink)  
Old 09-26-2009
Scrutinizer Scrutinizer is offline
Registered User
  
 

Join Date: Nov 2008
Posts: 621
This perhaps?
Code:
bash <(GET domain.tld parameter)
or
Code:
(GET domain.tld parameter)|bash
  #6 (permalink)  
Old 09-26-2009
Rhije Rhije is offline
Registered User
  
 

Join Date: Dec 2008
Posts: 103
radoulov - Thank you very very much, that worked perfectly! Now I need to go study more bash!
Reply

Bookmarks

Tags
bash, parameter, pipe, shell

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 08:58 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0