質問

I need to allow user input during ftp so that the user defines the final dircectory denoted by $HERE. my ftp is in a script that is then run by another script. I have tried passing an argv to the scritp but it says illegal number of arguments

my ftp is simply:

ftp -in <my.ftp      #which runs the script my.ftp which looks like this bellow:

open server 
user user passwd1      
cd /u/place/userarea/$HERE
mget FILE.FLE           
quit  

when I run the ftp script, I'd like it to ask a user for a number and then the script cd's into that directory.

Thanks

役に立ちましたか?

解決

Assuming my.ftp is a static file, you cannot expect your ftp client to resolve shell variables in that. Switch to an ftp client which has that capability, or use a here document:

read -p "Where? " HERE
ftp -in <<____EOF
    open server 
    user user passwd1      
    cd /u/place/userarea/$HERE
    mget FILE.FLE           
    quit  
____EOF
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top