Re: How to get argv[0] in alias for bashrc




veg_all@xxxxxxxxx wrote:
any clues how i can get alias to accept the ARGV[0] which is the first
command line argument:

# .bashrc

alias transfer='wget "http://www.$ARGV[0]/temp/transfer.gz";';

When I run it I get:

--22:03:20-- http://www.%5C044argv%5B0%5D/temp/transfer.gz
=> `transfer.gz'
Resolving www.\044argv[0]... failed: Name or service not known.

I looked into this once or twice and no go - the way to do it is from a
simple script, say in ~/bin

From the bash manual
<snip>
There is no mechanism for using arguments in the replacement
text. If
arguments are needed, a shell function should be used (see
FUNCTIONS
below).
</snip>

For what you want to do, this would work:


[khuang@xxxxxxxxxxxx ~]$ chmod +x bin/transfer
[khuang@xxxxxxxxxxxx ~]$ cat ~/bin/transfer
#!/bin/bash
wget http://www.${1}/temp/transfer.gz

[khuang@xxxxxxxxxxxx ~]$ transfer google.com
--09:38:46-- http://www.google.com/temp/transfer.gz
=> `transfer.gz'
Resolving www.google.com... 66.102.9.104, 66.102.9.99, 66.102.9.147
Connecting to www.google.com|66.102.9.104|:80... connected.
HTTP request sent, awaiting response... 404 Not Found
09:38:51 ERROR 404: Not Found.

[khuang@xxxxxxxxxxxx ~]$

.



Relevant Pages

  • Re: How to get argv[0] in alias for bashrc
    ... command line argument: ... Resolving www.\044argv... ... Under bash, you may want to use function instead of alias to take ...
    (comp.unix.shell)
  • How to get argv[0] in alias for bashrc
    ... any clues how i can get alias to accept the ARGVwhich is the first ... command line argument: ... Resolving www.\044argv... ...
    (comp.unix.shell)
  • Re: Another Button (link to website)
    ... Put this line of code in the On Click Event of the command button you want to ... The Shell function starts an application, ... VBA Help will give you more info if you need it. ... Private Sub cmdPayPal_Click ...
    (microsoft.public.access.modulesdaovba)
  • Re: shell function over network drive
    ... I will try your suggestion with the run command. ... you suspected I did not reinstall Microsoft Word - but that first part ... This shell function works fine if the file is on the C: ...
    (comp.databases.ms-access)
  • Re: Launch external file based on cell value
    ... You can use the Shell function to run a program. ... The following code will run "C:\Test\Test.exe" passing it a switch parameter whose value comes from column "C" of the row of the ActiveCell. ... Pearson Software Consulting LLC ... I want to be able to launch this file via command line code: "C:\Program ...
    (microsoft.public.excel.programming)