Tag Archives: FTP

How to exit a script with error ?

By Salil Gupta

Hi,

I have a script ABC which calls another script XYZ. Function of XYZ is to ftp a file from one server to another.

code for ABC:

Code:

#!/bin/ksh
PATH=/usr/bin

home/user/xyz "$@"

exit $?
~


code for xyz:

Code:

#!/bin/ksh
HOSTNAME=$1
SRCNAME=$2
DSTNAME=$3

### This file holds the outget of the FTP commands for success checking
FTPCHK=/tmp/ftpchk.$$
#touch $FTPCHK
echo "" > $FTPCHK

SRCFILE=$SRCNAME

DSTFILE=$DSTNAME

echo Source Host: $HOSTNAME
echo Source File Name: $SRCFILE
echo Destination File: $DSTFILE

echo `date` Beginning FTP download...
ftp -v ${HOSTNAME} <>$FTPCHK 2>&1
ascii
nlist ${SRCFILE}
get ${SRCFILE} ${DSTFILE}
quit
EOF

### Check for FTP errors
CHK1=`grep -c "226 Transfer complete." $FTPCHK`
CHK2=`grep -c "226 ASCII Transfer complete." $FTPCHK`
CHK3=`grep -ic "226 transfer complete" $FTPCHK`
CHK4=`grep -ic "226 File send OK." $FTPCHK`

### In NT, There should transmissions complete:
### One for the data transfer,
### One for the nlist

if [ $CHK1 -eq 2 ] || [ $CHK2 -eq 2 ] || [ $CHK1 -eq 1 -a $CHK2 -eq 1 ] || [ $CHK3 -eq 2 ] || [ $CHK4 -eq 1 ]; then
RC=0
echo "OK: FTP Transmission Worked"
echo '--------------------------------------------------------------'
cat $FTPCHK
echo '--------------------------------------------------------------'

else
RC=1
echo "ERROR: FTP Transmission Failed"
banner "ERROR"
echo '--------------------------------------------------------------'
cat $FTPCHK
echo '--------------------------------------------------------------'
fi

date
ls -al ${DSTFILE}

rm $FTPCHK

echo '---------------------------------------------------------------------'

exit $RC


In script XYZ, I am trying to ftp a file. So during ftp , whenever it shows that space is less than size of file, it should ftp the partial according to the available space and prompt a message about it and also prompt a message to outer script that inner script could not complete successfully. Hence resulting in the failure of outer script, due to partial ftp of file.

Also please post the comments about the each step of script to explain what is happening in that step. Thanks a lot in advance.

…read more

Source: FULL ARTICLE at The UNIX and Linux Forums

FTP connection refused issue

By sharsour

Hi All,

I am using the below script to get some files from the remote location

Code:


HOST='Test03'
USER='root'
PASSWD='*****'
FILE='/home/user/d.txt'
ftp -n $HOST <<END_SCRIPT
quote USER $USER
quote PASS $PASSWD
get $FILE
quit
END_SCRIPT
exit 0



But ist is giving me the error “Connection refused”

I am giving the right username , password and hostname. I dont have to apply the ssh-keys as i want to do it by giving password.

…read more

Source: FULL ARTICLE at The UNIX and Linux Forums

Unusual file-infecting malware steals FTP credentials, researchers say

A new version of a file-infecting malware program that’s being distributed through drive-by download attacks is also capable of stealing FTP (File Transfer Protocol) credentials, according to security researchers from antivirus firm Trend Micro.

The newly discovered variant is part of the PE_EXPIRO family of file infectors that was identified in 2010, the Trend Micro researchers said Monday in a blog post. However, this version’s information theft routine is unusual for this type of malware.

The new threat is distributed by luring users to malicious websites that host Java and PDF exploits as part of an exploit toolkit. If visitors’ browser plug-ins are not up to date, the malware will be installed on their computers.

The Java exploits are for the CVE-2012-1723 and CVE-2013-1493 remote code execution vulnerabilities that were patched by Oracle in June 2012 and March 2013 respectively.

To read this article in full or to leave a comment, please click here

…read more

Source: FULL ARTICLE at PCWorld

Vsftp upload error

By ment0smintz

Code:

# Example config file /etc/vsftpd/vsftpd.conf
#
# The default compiled in settings are fairly paranoid. This sample file
# loosens things up a bit, to make the ftp daemon more usable.
# Please see vsftpd.conf.5 for all compiled in defaults.
#
# READ THIS: This example file is NOT an exhaustive list of vsftpd options.
# Please read the vsftpd.conf.5 manual page to get a full idea of vsftpd's
# capabilities.
#
# Allow anonymous FTP? (Beware - allowed by default if you comment this out).
anonymous_enable=YES
#
# Uncomment this to allow local users to log in.
local_enable=YES
#
# Uncomment this to enable any form of FTP write command.
write_enable=YES
#
# Default umask for local users is 077. You may wish to change this to 022,
# if your users expect that (022 is used by most other ftpd's)
local_umask=002
#
# Uncomment this to allow the anonymous FTP user to upload files. This only
# has an effect if the above global write enable is activated. Also, you will
# obviously need to create a directory writable by the FTP user.
anon_upload_enable=YES
#
# Uncomment this if you want the anonymous FTP user to be able to create
# new directories.
#anon_mkdir_write_enable=YES
#
# Activate directory messages - messages given to remote users when they
# go into a certain directory.
#dirmessage_enable=YES
#
# Activate logging of uploads/downloads.
#xferlog_enable=YES
#
# Make sure PORT transfer connections originate from port 20 (ftp-data).
#connect_from_port_20=YES
#
# If you want, you can arrange for uploaded anonymous files to be owned by
# a different user. Note! Using "root" for uploaded files is not
# recommended!
#chown_uploads=YES
#chown_username=whoever
#
# You may override where the log file goes if you like. The default is shown
# below.
#xferlog_file=/var/log/vsftpd.log
#
# If you want, you can have your log file in standard ftpd xferlog format.
# Note that the default log file location is /var/log/xferlog in this case.
#xferlog_std_format=YES
#
# You may change the default value for timing out an idle session.
#idle_session_timeout=600
#
# You may change the default value for timing out a data connection.
#data_connection_timeout=120
#
# It is recommended that you define on your system a unique user which the
# ftp server can use as a totally isolated and unprivileged user.
# nopriv_user=ftpsecure
#
# Enable this and the server will recognise asynchronous ABOR requests. Not
# recommended for security (the code is non-trivial). Not enabling it,
# however, may confuse older FTP clients.
# async_abor_enable=YES
#
# By default the server will pretend to allow ASCII mode but in fact ignore
# the request. Turn on the below options to have the server actually do ASCII
# mangling on files when in ASCII mode.
# Beware that on some FTP servers, ASCII support allows a denial of service
# attack (DoS) via the command "SIZE /big/file" in ASCII mode. vsftpd
# predicted this attack and ...read more

Source: FULL ARTICLE at The UNIX and Linux Forums

FTP Status check(whether it is suuccessful or not)

By Kannannair

Hi Friends

I need to check the status of FTP connection i.e. Whether it is successful or not

I have tried this by assigning the FTP connection script to a variable and after that using this variable I tried to check the status.

In the below code snippet I am trying to assign the FTP conenction status to a variable.

Code:


STATUS=`ftp -n $HOST <<EOF
quote USER $USER
quote PASS $PASSWD
prompt off
cd /user/sba-appl/test/sscr/ramu/
lcd /user/sba-appl/productie/sscr/darshan
mget get.DAT
bye
EOF`


Can anyone tell whether this approach is correct or not. When i am trying this method FTP connection is not happening. Whether we can assign the FTP connection like this

Because after this i can use the above variable and check the status for various FTP states like 226 553etc using the grep command.

Thanks and Regards
Darshan

From: http://www.unix.com/shell-programming-scripting/221797-ftp-status-check-whether-suuccessful-not.html

FTP Status check(whether it is successful or not)

By Kannannair

Hi Friends

I need to check the status of FTP connection i.e. Whether it is successful or not

I have tried this by assigning the FTP connection script to a variable and after that using this variable I tried to check the status.

In the below code snippet I am trying to assign the FTP conenction status to a variable.

Code:


STATUS=`ftp -n $HOST <<EOF
quote USER $USER
quote PASS $PASSWD
prompt off
cd /user/sba-appl/test/sscr/ramu/
lcd /user/sba-appl/productie/sscr/darshan
mget get.DAT
bye
EOF`


Can anyone tell whether this approach is correct or not. When i am trying this method FTP connection is not happening. Whether we can assign the FTP connection like this

Because after this i can use the above variable and check the status for various FTP states like 226 553etc using the grep command.

Thanks and Regards
Darshan

From: http://www.unix.com/shell-programming-scripting/221797-ftp-status-check-whether-successful-not.html

Listing Files and Sizes on FTP server

By ajayram_arya

Need assistance in getting File size for the List of files using perl script . I have writtern 2 codes. One of them gives me the list of files and 2nd one give me the size for only 1 file.

I dont know how to club both of them to get the list of files with its size .

Code:

#!/usr/bin/perl -w
use Net::FTP;
$ftp = Net::FTP->new("hostname");
$ftp->login('userid', 'password');
$ftp->cwd("/pub");
#$ftp->binary;
#my $files=$ftp->ls();

my @filenames=$ftp->ls();
foreach (@filenames)
{
print "$_n" ;
}


Code:

#!/usr/bin/perl -w
use Net::FTP;
my $host="hostname";
my $user="userid";
my $pw = "password";
my $path="/pub";
my $file="Filename ";
my $ftp = Net::FTP->new($host);

$ftp->login($user, $pw);
$ftp->cwd($path) , $ftp->message;
$ftp->binary;
print "FTP $file : Size = [", $ftp->size($file), "] n";
$ftp->quit();


From: http://www.unix.com/shell-programming-scripting/221393-listing-files-sizes-ftp-server.html

Help Simple FTP Script Here Syntax

By gdotoli

I have a list of IP address and want to be assess whether FTP is allowing
FTP access. I don’t want to use lousy NT shell, but cannot get the syntax down on this. ftphosts.txt is a simple list of IP adresses.
I want to iterate through the IPS and do a simple

ftp IPadress
user ftp password test@abc.org
Then lcd to c:investigate and get all the files in the root.
Please help me with this syntax. I am running this in a Cygwin bash shell.
Thak you in advance for your help!
Gregg Dotoli

#!/bin/bash -vx
for g in `cat ftphosts.txt`; do echo $g
ftp -u $g<<++EOT++
user ftp ftp@anonymous.com
bin
lcd c:investigate
hash
bell
mget *.*
user <ftp@aol.com>
bin
mget *.*
quit
++EOT++

From: http://www.unix.com/shell-programming-scripting/221271-help-simple-ftp-script-here-syntax.html

The Internet Archive's trove of historical software dwarfs all others, archivist claims

The past doesn’t always fade into oblivion.

For the past two years, computer archivist Jason Scott has been hard at work helping to improve the Internet Archive’s storehouse of historical software from classic PC games to old BBS content. On Saturday, Scott made a bold announcement, claiming the Internet Archive now houses the largest historical software collection in the world.

“My provided goal was do for software what archive.org has been doing for [books, music, visual items, and Websites],” Scott said on his personal blog. “In short summary, I have done that.” Scott didn’t disclose the software collection’s exact size, only that it is comprised of terabytes of data.

If you’re a computer history buff, the Internet Archive’s software collection includes a variety of old programs, games, and utilities you can download. The archive is split into several sections, including the Shareware CD archive, PC games, mirrors of old FTP sites, programs pulled from old disk drives, and The Old School Emulation Center (TOSEC) for firmware and programs of classic computers and game consoles.

To read this article in full or to leave a comment, please click here

From: http://www.pcworld.com/article/2034656/the-internet-archives-trove-of-historical-software-dwarfs-all-others-archivist-claims.html#tk.rss_all

Hackers turn a Canon EOS camera into a remote surveillance tool

The high-end Canon EOS-1D X camera can be hacked for use as a remote surveillance tool, with images remotely downloaded, erased and uploaded, a researcher said during the Hack in the Box security conference in Amsterdam on Wednesday.

The digital SLR camera has a Ethernet port and also supports wireless connection via a WLAN adapter. That connectivity is particularly useful for photojournalists who can quickly upload the photos to a FTP server or a tablet, according to German security researcher Daniel Mende of ERNW.

However, the camera’s connectivity was not designed with security in mind, said Mende. “If a photographer uses an insecure network like a hotel Wi-Fi network or a Starbucks network, than almost anybody with a little bit of knowledge is able to download images from the camera,” he said.

The camera can be accessed by attackers in a number of ways, Mende said. Because FTP upload mode sends information in clear text, credentials and the complete data transmission can be sniffed, so uploaded pictures can be extracted from the network traffic, Mende said.

To read this article in full or to leave a comment, please click here

…read more

Source: FULL ARTICLE at PCWorld

Connecting to a server using FTP is hanging

By Kannannair

File Type: jpg
Hi Friends

I have created a shell script to connect to a windows server. But the problem is while trying to run the script I am not getting any output. After running the script it is hanged and the prompt is not showing until if I press the ctrl+Z to break the script. I also tried using the FTP command but here also I am getting the “Connecting to server address” meaasge and after that it is hanged.

I checked using telnet and it is working but while doing telnet it is asking for the username and password and the FTp port 21 is opened also. For your refrence I am attching the screenshot of FTP.

Can anybody tell me why this is coming.

Thanks and Regards
Darshan

…read more

Source: FULL ARTICLE at The UNIX and Linux Forums

Implement FTP server on RHEL server without using FTP client

By RHCE

We have RHEL 5.8 in our environment, I had a query whether we can implement an FTP server using vsftpd package and Linux configurations like setsebool without using any external FTP clients like FileZilla etc. I am very confused on this. The FTP functionalities that should be present are download & upload of files. My observation is that the download of files is not an issue but the upload of files maybe requiring an FTP client.

I hope, my query is clear that can we implement an FTP server on RHEL server without using any external FTP client?

Please revert with the reply to my query as I am very confused on this.

Regards

…read more

Source: FULL ARTICLE at The UNIX and Linux Forums

How to display files of server2 in server1?

By Little

hi,

i have two servers in unix. say server1 and server2. my shell script is running on server1.

In server2, there is a directory (/etc/data/) which contains some text files.

I want to write the list of filenames in server2 in a file and display the file in server1.

In short, i want to display the filenames present in server2 in server1.

i thought i can use FTP like..

Code:

ftp server2 <<FTP1
quote USER aaaa
quote PASS bbbb
cd /etc/data
Files=`ls -l | cut -c45-`
FTP1


In the aboce code i tried to populate a variable with the file names which are present in server2, but it doesnt work.

can any1 help doing this? or suggest some other method..

Thanks

…read more

Source: FULL ARTICLE at The UNIX and Linux Forums

Canon U.S.A. Introduces Two Ultra-Compact Professional Camcorders Enabling Wireless Digital Content

By Business Wirevia The Motley Fool

Filed under:

Canon U.S.A. Introduces Two Ultra-Compact Professional Camcorders Enabling Wireless Digital Content Transfer and Remote Operation

New Canon XA25 and XA20 Camcorders Include a 20x HD Zoom Lens, Simultaneous MP4 and AVCHD Recording, a 3.5-Inch Organic LED Touch Panel Display, and Wireless Connectivity for Digital Content Uploading or Remote Operation Via Tablet or Smartphone

MELVILLE, N.Y.–(BUSINESS WIRE)– Strategically integrating some of Canon’s sophisticated next-generation imaging and wireless technologies, the new XA25 HD and XA20 HD professional camcorders from Canon U.S.A., Inc., a leader in digital imaging solutions, provide an impressive combination of professional features and optics in a compact design. Ideal for run-and-gun style videography, or electronic newsgathering (ENG), both models weigh only 2.6 pounds, allowing for extreme mobility and portability. Both camcorders feature multiple shooting-assist functions and enhanced key components such as a newly developed Genuine Canon wide-angle 20x HD zoom lens with an ENG-style “rocker” zoom control and built-in real-time optical image stabilization. Delivering outstanding low-light performance and image quality, the Canon XA25 and XA20 HD camcorders are equipped with a new high-sensitivity 2.91-megapixel 1/2.84-inch HD CMOS image sensor and the new Canon DIGIC DV 4 image processor.

Additional features include simultaneous recording of multiple bit rates and Full 1080p HD formats – including 60p and native cinematic at 24p – on two separate SD cards. Users can simultaneously record Full 1080p HD video at 60p in either AVCHD Progressive (28Mbps) or MP4 (35Mbps) format for crisp moving images, or record at a lower bit rate and transmit MP4 (3Mbps) format video to cover and quickly upload breaking news via wireless FTP file transfer. The cameras’ dual SD slots allow for relay recording for long periods without interruption.

“The nearly instantaneous rate by which video news is consumed and shared via TV, tablets and smartphones has fueled the immediacy by which journalists need to capture and deliver their content. The introduction of the XA25 and XA20 professional camcorder models are designed to provide these professionals with a compact, portable, and wireless system for content acquisition and uploading,” stated Yuichi Ishizuka, executive vice president and general manager, Imaging Technologies & Communications Group, Canon U.S.A. “In addition, the tremendous growth of independent and documentary filmmaking as well as innovative, creative online content may also benefit from the compact design, high-quality formats and long-range optics found in both models.”

Advanced Canon Optics

Drawing from the …read more
Source: FULL ARTICLE at DailyFinance

The Perfect Desktop – OpenSUSE 12.3 (GNOME Desktop)

 
 

HowtoForge: This tutorial shows how you can set up an OpenSUSE 12.3 desktop that is a full-fledged replacement for a Windows desktop, i.e. that has all the software that people need to do the things they do on their Windows desktops. The advantages are clear: you get a secure system without DRM restrictions that works even on old hardware, and the best thing is: all software comes free of charge.

The software I propose as default is the one I found easiest to use and best in their functionality – this won’t necessarily be true for your needs, thus you are welcome to try out the applications listed as alternatives.

I do not issue any guarantee that this will work for you!

 

1 Preliminary Note

To fully replace a Windows desktop, I want the OpenSUSE 12.3 desktop to have the following software installed:

Graphics:

  • Pinta – open source drawing application modeled after Paint.NET
  • KolourPaint – paint application with elemental functions
  • The GIMP – free software replacement for Adobe Photoshop
  • Shotwell Photo Manager – full-featured personal photo management application for the GNOME desktop

Internet:

  • Firefox
  • Opera
  • Chromium – Google’s open-source browser
  • Thunderbird – email and news client
  • Evolution – combines e-mail, calendar, address book, and task list management functions
  • Deluge – free cross-platform BitTorrent client
  • Transmission BitTorrent Client – Bittorrent client
  • qBittorrent – free alternative to µtorrent
  • Marble – desktop globe similar to google earth
  • GoogleEarth – Google’s desktop globe
  • Flash Player 11
  • FileZilla – multithreaded FTP client
  • Pidgin IM Client – multi-platform instant messaging client
  • Skype (only for 32 bit systems)
  • Dropbox Client – cloud storage
  • Gwibber Social Client – open-source microblogging client (Twitter, Facebook, etc.)

Office:

  • Adobe Reader
  • Evince – document viewer
  • Okular – document viewer
  • LibreOffice Writer – replacement for Microsoft Word
  • LibreOffice Calc – replacement for Microsoft Excel
  • GnuCash – double-entry book-keeping personal finance system, similar to Quicken
  • Scribus – open source desktop publishing (DTP) application

Sound & Video:

  • Banshee – audio player, can encode/decode various formats and synchronize music with Apple iPods
  • Amarok – audio player
  • MPlayer – media player (video/audio), supports WMA
  • Rhythmbox Music Player – audio player, similar to Apple’s iTunes, with support for iPods
  • gtkPod – software similar to Apple’s iTunes, supports iPod, iPod nano, iPod shuffle, iPod photo, and iPod mini
  • Sound Juicer CD Extractor – CD ripping tool, supports various audio codecs
  • XMMS – audio player similar to Winamp
  • Clementine – Amarok 1.4 fork
  • VLC Media Player – media player, plays all kinds of videos (video/audio)
  • Totem – media player (video/audio)
  • Xine – media player, supports various formats; can play DVDs
  • Winff – free video converter
  • SoundConverter – free audio converter
  • Soundkonverter – free audio converter
  • K3B – CD/DVD burning program
  • Brasero – CD/DVD burning program
  • Audacity – free, open source, cross platform digital audio editor
  • Kino – free digital video editor
  • dvd::rip – full featured DVD copy program
  • Multimedia Codecs

Programming:

  • Bluefish – text editor, suitable for many programming and markup languages
  • Eclipse Extensible Tool Platform and Java IDE

Other:

  • VirtualBox – lets you run your old Windows desktop as a virtual machine under your Linux desktop, so you don’t have to entirely abandon Windows
  • TrueType fonts
  • Java
  • gedit – simple text editor

The software provided in the above list covers most of the basic tasks one might need to do on their desktop computers, sometimes there are multiple choices for same functionality. If you know which one you like best, you obviously don’t need to install and test the other applications, however if you like choice, then of course you can install more than one.

I’m using the OpenSUSE 12.3 Live-DVD in this tutorial to set up the system. You can download it from here: http://software.opensuse.org/123/en

I will use the username howtoforge in this tutorial, and I will download all necessary files to howtoforge’s desktop which is equivalent to the directory /home/howtoforge/Desktop. If you use another username, please replace howtoforge with your own username. So when I use a command such as

cd /home/howtoforge/Desktop

you must replace howtoforge.

 

2 Installing The Base System

Download the OpenSUSE 12.3 Live-DVD iso image, burn it onto a DVD, and boot your computer from it. Select Installation.

OpenSUSE

Continue reading this article at it’s original source:
http://www.howtoforge.com/the-perfect-desktop-opensuse-12.3-gnome-desktop

Source: FULL ARTICLE at Linux Today

Execution problem with the FTP shellscript

By Kannannair

Hi Friends

I am new to the shell script and i have a script which will connect to server enviornment which will read a file and will FTP to an another server location. But while executing this script FTP transfer is not occuring. But when I enter in FTP mode I am able to transfer the file from one server to another.

Script is

Code:


#!/bin/sh
FILE_NAME="/user/sba-appl/productie/sscr/ramu/dd.DAT"
HOST='130.144.240.108'
USER='user name'
PASSWD='password'
ftp -nv <<EOF
open $HOST
user $USER $PASSWD
cd /user/sba-appl/test/sscr/ramu
put $FILE_NAME
EOF


The error which I am getting is 553. The problem is I cant change the chmod permission of the target server as it is an production server. the root directory user doesnt have a write permission. But while using FTP mode I am able to write the the file but through script I am getting 553 error.Can anybody tell me how to solve this problem.Whether I can use symbolic links??. But If i am able to transfer the file using th FTP mode why it is not working with the script??

…read more
Source: FULL ARTICLE at The UNIX and Linux Forums

Replace FTP with SFTP

By desai.vishnu

Hi All,

I am in the process of replacing SFTP instead of FTP to make data more secure. In one of my FTP script I have Quote Site command. I would like to know, what is the option to replace this in SFTP

Code:

ftp -n -v </dev/null
open $remote_address
user ${remote_login_id} ${remote_password}
quote site $quote_site_cmd
cd $remote_dir
binary
put $local_file $remote_file
quit


Please help me to solve this.

Thanks in advance
Vishnu

…read more
Source: FULL ARTICLE at The UNIX and Linux Forums