Sponsored Content
Top Forums Shell Programming and Scripting expanding alias from a variable Post 302357306 by peterro on Tuesday 29th of September 2009 10:24:38 AM
Old 09-29-2009
Your code isn't consistent even with similar lines. Remove the semi-colons from the end of the lines. Your 'read' lines aren't the same throughout the script either:

Code:
#!/bin/sh

echo "Servernumber:"
read srv
echo "remotefile incl. abs. path"
read remotefile
echo "localfile incl. abs.path"
read localfile

scp admin@$srv:$remotefile $localfile

A good method for testing techniques/syntax is to pull just the technique out into a simple 2-3 line script to validate that the code works and then put it into your script.

Something like:

Code:
read something
echo $something

or

Code:
srv=box
remotefile=/file
localfile=/another/file
scp admin@$srv:$remotefile $localfile

 

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
IFP(1)							      General Commands Manual							    IFP(1)

NAME
ifp - access iRiver iFP audio devices SYNOPSIS
ifp command [arguments ...] DESCRIPTION
ifp lets you manage your music on an iRiver iFP music player acting in "Manager Mode". If your player is using "UMS Mode", then you don't need this program; it will appear as new drive when you plug it in. This manual page documents the version of ifp included as an example application for the libifp library. The interface is intended to mimic the ifp binary found in the ifp-line binary package. ifp can upload or download files or directories, delete or make directories on the device, format the device, or upgrade your firmware. COMMANDS
ls [directory] List the files and directories on the device. The root directory is /. Directories are preceded with 'd' and other files with 'f'. df Display total and free space on the device. upload localfile remotefile Copy the file named localfile to the iFP device, and name it remotefile. (This is like cp.) upload localfile remotedir Copy the file named localfile to the iFP device, into remotedir. (This is like cp.) upload localdir remotedir Copy the entire directory localdir to the device, into remotedir. This copies into a subdirectory, so upload foo / puts files from the directory foo info /foo on the device. (This is like cp -R.) This uploads the entire directory, not just audio files. put localfile | localdir Upload the file or directory to the device, with the same name it has locally. If a directory is given, it is put in /. download remotefile localfile download remotefile localdir download remotedir localdir Like upload, but copies from the iFP device to your system. Some proprietary file types may not be downloaded. get remotefile | remotedir Like put, but copies files or directories from the device to your current working directory. rm [-r] file Delete (recursively) a file (or directory) on the device. rmdir dir Delete an empty directory on the device. mkdir dir Create a directory on the device. battery Display battery status of the device. typestring Display the model number of the device. firmversion Display the firmware revision currently on the device. format Reformat the device's memory. This will delete all your music. firmupdate FIRMWARE.HEX Upload the file FIRMWARE.HEX as new firmware for the device. This will not delete your music, but may have many other detrimental effects. Don't turn the device off or unplug it while the firmware is updating, and don't attempt to upload new firmware with a low battery. AUTHORS
libifp was written by Geoff Oakham, based on ifp by Yamashiro Jun. This manual page was written for Debian by Joe Wreschnig <piman@debian.org>, but may be used by others. May 30th, 2004 IFP(1)
All times are GMT -4. The time now is 10:23 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy