How to redirect output of a command to a variable during ftp mode?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to redirect output of a command to a variable during ftp mode?
# 1  
Old 07-25-2013
How to redirect output of a command to a variable during ftp mode?

Hi,

How can I redirect the output of a following command to a variable.

Code:
ftp myservername
ftp> user
(username) guptaji
331 Password required for guptaji.
Password:
ftp> size /home/salil/abc.dat
ftp> a='size /home/salil/abc.dat'
?Invalid command

I want to redirect value of size to some variable and during ftp it is showing invalid command error
Actually I need to compare this size(of remote file) with available disk space on my local machine.

So also tell me how can I convert the available disk space on my local machine in bytes and then compare it with remote file size.

Thanks a lot for your time.
Salil

Last edited by Salil Gupta; 07-25-2013 at 03:41 AM.. Reason: forgot to include error
# 2  
Old 07-25-2013
It is not FTP 'mode', it is the program FTP, which does not understand variables, loops, comparisons, or anything else.

To feed the results into shell, you have to feed the results into shell.

Code:
ftp servername <<EOF >outputfile
command1
command2
quit
EOF

parse_output_of_outputfile

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to redirect the output of a command inside ftp block?

hi, i am using ftp to get files from remote server. inside the ftp i want to us ls -ltr command and send the output of it to a file. ftp -n remote_server <<_FTP quote USER username quote PASS password prompt noprompt pwd ls -ltr get s1.txt bye _FTP i... (4 Replies)
Discussion started by: Little
4 Replies

2. Shell Programming and Scripting

How to redirect 'crontab' output to a variable?

I'm trying to redirect the output of crontab to a variable named "crontab_status" as below: crontab_status=$(crontab -l) executing the script is not redirecting to the variable. Please help! (6 Replies)
Discussion started by: mjavalkar
6 Replies

3. Shell Programming and Scripting

Redirect output from SQL to unix variable

Hi, I have a requirement to store oracle sqlplus output to some unix variable, count the records and then print the output on the screen. Can you please point me to any sample program for reference purpose. Thanks a lot for your time. (0 Replies)
Discussion started by: bhupinder08
0 Replies

4. AIX

Not able to redirect output of command

Hi All,. We are using AIX as the OS to host the Oracle ERP. We have a command FNDLOAD which is used to load setups. When this command is run, it outputs names of log files and any errors to the screen. I am trying to redirect this output to a file because we have large number of these... (4 Replies)
Discussion started by: mansmaan
4 Replies

5. Shell Programming and Scripting

redirect the grep output into the variable

i want to redirect the grep output into the variable but i am not able to get it i tried veri=`grep -i $1 "${logdir}"* | grep -i adding | grep -iv equation | tail -1 | cut -d ':' -f 1` vari=$(grep -i $1 "${logdir}"* | grep -i adding | grep -iv equation | tail -1 | cut -d ':' -f 1) BUT NOT... (1 Reply)
Discussion started by: mail2sant
1 Replies

6. Shell Programming and Scripting

redirect output of dos2unix command

hi I want to suppress the output of dos2unix command in my shell script. I'm using follwing command in my script dos2unix somefile >/dev/null But it's still showing output while executing the script.Please help me to sort this out Thanks (4 Replies)
Discussion started by: nrbhole
4 Replies

7. Shell Programming and Scripting

awk redirect output to shell variable

I'm trying to redirect awk's output to a BASH variable. Currently the statement looks like this options=`awk '{ while (i < NF) { print $i; ++i } }' answer but for some reason that makes $options look like this: 1 2 3 4 1 2 3 Now, the input file 'answer' is taken from a dialog... (3 Replies)
Discussion started by: dhinge
3 Replies

8. UNIX for Dummies Questions & Answers

Redirect Output In Variable

how make assign the output of the command (for example: grep "file" "string" ) in a variable ($name)? i thing how put the result of the command (grep , cut, find ecc) in a variable.. IT's Possible ?? (1 Reply)
Discussion started by: ZINGARO
1 Replies

9. Shell Programming and Scripting

redirect output of FTP

Hi, I call the FTP command from within a script. The call to FTP looks like this : ftp -n -i -v < $com >> "$logfile" Where $com is a commandfile and I want the output to be redirected to $logfile. If I do this call at the prompt it works perfect. (replacing the variables by there... (4 Replies)
Discussion started by: kcaluwae
4 Replies

10. UNIX for Dummies Questions & Answers

redirect command output to variable

Hi, I am looking for a way to redirect the result from a command into a variable. This is the scenario. Using the find command I will be getting multiple records/lines back. Here is the command I am using: find /”path”/ -name nohup.out -print This now is giving me the paths and file... (1 Reply)
Discussion started by: hugow
1 Replies
Login or Register to Ask a Question