Sponsored Content
Top Forums Shell Programming and Scripting expanding alias from a variable Post 302357408 by locutus01 on Tuesday 29th of September 2009 05:54:41 PM
Old 09-29-2009
Quote:
Originally Posted by dr.house
Code:
#! /bin/bash

echo -n "Server no.:  " ; read server
echo -n "Remote file: " ; read remote
echo -n "Local file:  " ; read local

echo "SCP:> $server $remote $local"

exit 0

Code:
[house@leonov] sh test.bash
Server no.:  12
Remote file: this
Local file:  that
SCP:> 12 this that

Ok, but this does not expand the alias for the servername.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Expanding shell variable

I have a question about expanding shell variables. Given the following piece of script: a="Some text" b="Other text" for i in a b do string1=$i echo $string1 --> returns 'a' string2=EXPRESSION_WITH_$i echo $string2 --> returns 'Some text' done ... (2 Replies)
Discussion started by: lonar
2 Replies

2. UNIX for Dummies Questions & Answers

Alias with variable?

I'm new to UNIX. I have to run executables often, and they all have a common prefix "prefix_". Now I'm wondering if I can make an alias where I can type run xyz that will then execute "./prefix_xyz" ? Thanks in advance. (1 Reply)
Discussion started by: JustinT
1 Replies

3. Solaris

Variable not expanding during Solaris pkgadd

I'm having a little trouble with a Solaris package build/install. I have the following entries in my prototype file... # Interfaces file - all versions installed and auto linked to installation type... f none $OPTDIR/config/interfaces.DEV 0444 $OWNER $GROUP f none... (0 Replies)
Discussion started by: JerryHone
0 Replies

4. UNIX for Dummies Questions & Answers

Passing variable to Alias in Hp kshell

Hi all, I have a series of directories which i open regularly. I want create an alias so that i can pass the direcotry name to alias and then this commands makes Cd to the path i need. COuld you please help on how to create an alias ex of what i am trying but couldn't succeeded #alias... (1 Reply)
Discussion started by: firestar
1 Replies

5. UNIX for Dummies Questions & Answers

Create alias files (not alias commands)

If one: $ find -name 'some expression' -type f > newfile and then subsequently wants to create an alias file from each pathname the find command retrieved and the > placed within 'newfile', how would one do this? Ideally, the newly created alias files would all be in one directory. I am... (3 Replies)
Discussion started by: Alexander4444
3 Replies

6. Shell Programming and Scripting

awk alias passing a value to a variable

I am trying to turn this into an alias with no luck. I would then like to put the alias into my bashrc file. I know awk is very picky about quotes. I have tried every version of quotes, single quotes, double quotes, and backslashes that I can think of. VAR=$(xrandr | awk '$2=="connected"{s=$1}... (3 Replies)
Discussion started by: cokedude
3 Replies

7. Shell Programming and Scripting

use variable in alias

Hi Guys, aliase uniq get ut=XXX anistr|availyStus|oratate|uniqueid I want to create aliase but i want xxx as variable..... run like this uniq ak123 uniq ak324 uniq ak123 End of the story i want to use variable in aliase command (5 Replies)
Discussion started by: asavaliya
5 Replies

8. Shell Programming and Scripting

Quick question on expanding variable

s=`awk '{ print $0}' /Applications/Relink.app/z_cloudline.txt` sed -n '"$s"' /var/mobile/Library/iFile/Bookmarks.plist > /var/mobile/originalip.txt What is the problem with that code ? With variable it only outputs: sed: -e expression #1, char 1: unknown command: `"' If I use the... (3 Replies)
Discussion started by: pasc
3 Replies

9. Shell Programming and Scripting

Expanding a globed variable name

Heyas I'm trying to give some information on used variables. While the first two work fine, the ones starting with a glob (is that the proper term?) fail. echo ${!TUI_*} ${!RET_*} ${!*_CLI} ${!*\_GUI} bash: ${!*_CLI}: bad substitution Same with @ or have them escaped. I found no... (2 Replies)
Discussion started by: sea
2 Replies

10. UNIX for Beginners Questions & Answers

Sed variable not expanding

I have also some difficulty calling sed to change a word in a file. sed -i 's/docTitl/Outline ${docTitl}/g' $ofln Moved to new thread, since it is a different question (3 Replies)
Discussion started by: Danette
3 Replies
FTP_NB_GET(3)								 1							     FTP_NB_GET(3)

ftp_nb_get - Retrieves a file from the FTP server and writes it to a local file (non-blocking)

SYNOPSIS
int ftp_nb_get (resource $ftp_stream, string $local_file, string $remote_file, int $mode, [int $resumepos]) DESCRIPTION
ftp_nb_get(3) retrieves a remote file from the FTP server, and saves it into a local file. The difference between this function and ftp_get(3) is that this function retrieves the file asynchronously, so your program can perform other operations while the file is being downloaded. PARAMETERS
o $ftp_stream - The link identifier of the FTP connection. o $local_file - The local file path (will be overwritten if the file already exists). o $remote_file - The remote file path. o $mode - The transfer mode. Must be either FTP_ASCII or FTP_BINARY. o $resumepos -The position in the remote file to start downloading from. RETURN VALUES
Returns FTP_FAILED or FTP_FINISHED or FTP_MOREDATA. EXAMPLES
Example #1 ftp_nb_get(3) example <?php // Initate the download $ret = ftp_nb_get($my_connection, "test", "README", FTP_BINARY); while ($ret == FTP_MOREDATA) { // Do whatever you want echo "."; // Continue downloading... $ret = ftp_nb_continue($my_connection); } if ($ret != FTP_FINISHED) { echo "There was an error downloading the file..."; exit(1); } ?> Example #2 Resuming a download with ftp_nb_get(3) <?php // Initate $ret = ftp_nb_get($my_connection, "test", "README", FTP_BINARY, filesize("test")); // OR: $ret = ftp_nb_get($my_connection, "test", "README", // FTP_BINARY, FTP_AUTORESUME); while ($ret == FTP_MOREDATA) { // Do whatever you want echo "."; // Continue downloading... $ret = ftp_nb_continue($my_connection); } if ($ret != FTP_FINISHED) { echo "There was an error downloading the file..."; exit(1); } ?> Example #3 Resuming a download at position 100 to a new file with ftp_nb_get(3) <?php // Disable Autoseek ftp_set_option($my_connection, FTP_AUTOSEEK, false); // Initiate $ret = ftp_nb_get($my_connection, "newfile", "README", FTP_BINARY, 100); while ($ret == FTP_MOREDATA) { /* ... */ // Continue downloading... $ret = ftp_nb_continue($my_connection); } ?> In the example above, newfile is 100 bytes smaller than README on the FTP server because we started reading at offset 100. If we didn't disable FTP_AUTOSEEK, the first 100 bytes of newfile would be ''. SEE ALSO
ftp_nb_fget(3), ftp_nb_continue(3), ftp_fget(3), ftp_get(3). PHP Documentation Group FTP_NB_GET(3)
All times are GMT -4. The time now is 07:44 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy