Discussion Locked

Solaris 2.6: 1) running ftp from shell s

0 helpful
21 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Sorry forthese simple questions:

1. I need to automate my daily file upload
through an ftp session.

Is there any way to supply a password
to the standard ftp client from UNIX
shell script ?

I also found some tips (ftp man page)
as to how to use .netrc file for
ftp 'autologin' mode. However it does
not seem to work either... at least
I cannot find how to force ftp into
this autologin mode.

I would highly appreciate any help.

2. I am looking for Sun Solaris 2.6
commands which can provide some
statistics regarding memory usage,
paging/swapping, disk and network I/O.

Thanks in advance,

Jerry.

21 replies

by hasse mcse/brainbench

Hi!

This is the link you need for question number two.

http://www.sunfreeware.com/

In the frame to the right click on the OS version and architecture you are running.

Then in the lower right frame scrol down and look for a program calledtop.

Download and use pkg tools to install.
This program will give info about a by you specified number of running process and their mem, cpu utilization as well as user, group, id and such.

At the top program will disply total memore usage, cpu utilization by system and users, swap utilization and a few others.

Search around that site and you probably find something similiar for the network.

As for your first question I use ncftp instead.

With ncftp you'll get a few batch scripting programs such as ncftpget, ncftpput, ncftpls...

Checkout:
http://www.ncftp.com/

for more info and download of both sources and binaries.

Click the link for clients and get version 3.0.1.

/Hasse

by debbie.lynn

In answer to question 1.

Firstly create a .netrc file in the users home directory, Ensure the file is owned by the user and the permissions are 600.

The entry within the .netrc should be as follows:-

machine {remote machine name} login {login name} password {passwd}

Within your shell script you then issue the ftp command using the following:-
ftp -i << EOF
put {filename}
EOF

Hope this helps...

by debbie.lynn

In answer to question 2.

You will also be able to see these stats real time using "sar". Look in man pages for list of commands.

by ustutz

For the ftp question: You do not need an ".netrc" file:

From cron - or where ever - execute:

ftp -i -n < script.file

script.file contains:

open host1

user myname mypassword

put /path1/file1
put /path2/file2
mput /path3/file*

close
quit

ftp command options: "-i" disables interactive prompting - needed for the mput/mget commands. "-n" disables 'auto login', i.e., no interactive prompting for username / password.

by spepper

1)requires appropriate .netrc file

#!/bin/sh
# ftper - ftps the file named in second parameter to the machine named in the
# first parameter. renames the file to the name given in the third parameter
# requires an appropriate entry in .netrc
# Usage: ftper machine localfile remotefile username
if [ $# -lt 4 ] ; then
echo "Usage: ftper machine localfile remotefile username"
else
SOURCE=$1
FILE=$2
NEWFILE=$3
USER=$4
#start of ftp session
ftp $SOURCE <

by spepper

2) some suggested commands to look up in the man pages:
auditstat(1M)
cachefsstat(1M)
ff(1M)
ff_ufs(1M)
iostat(1M)
lockstat(1M)
mpstat(1M)
nfsstat(1M)
nisstat(1M)
rpc.rstatd(1M)
syncstat(1M)
vmstat(1M)

by mbitto

1. YES.
ftp -i -n -v target_machine << EOF
user username
delete /tmp/flagfile
quit
EOF
2. System info - vmstat or sar
disk/I/O info : iostat
There are also a number of freeware utilities that enhance the experience!

by pvz

Jerry,

1.) You don't need to do anything to enable auto-login. When you start the FTP client, if the '-n' switch is not used, it will automatically check for .netrc. If an entry matching the target server is found, it will use the userid/password specified for the login. The target server specifications must be consistent - if you use hostname in .netrc, you must use hostname for the FTP; if you use IP Address in .netrc, you must use IP address for the FTP.

2.) Try vmstat, mpstat, iostat, & SAR.

Peter

by chris

1.
#Start Script
--- cut here ----
#!/bin/sh
USER="anonymous"
PASS="not_telling"
FTPHOST="ftp.cdrom.com"
FILE="a.out"
SCRIPT="/tmp/ftp.$$"
LOG="/tmp/ftp.$$.log"
# Create file $SCRIPT with automated ftp commands in it.
echo "user $USER@$HOST $PASS" > $SCRIPT
echo "bin" >> $SCRIPT
echo "put $FILE" >> $SCRIPT
echo "bye" >> $SCRIPT
# Execute FTP using the $SCRIPT file as input.
/usr/bin/ftp -n ${FTPHOST} < $SCRIPT >> $LOG
#cleanup the file with the FTP commands in it.
rm $SCRIPT
# End script

2.

sar -A
MemTool (package)ftp://playground.sun.com/pub/memtool
SE (package) Available from http://www.sun.com/sun-on-net/performance/se3

Hope this helps.
Chris Shoesmith

This discussion is closed to new replies.