Shell Script FTP Login

Hi,
I want to call a shell script ftp to connect to a server, below the code of my file:
ftp -n <<BODY
open 172.30.10.XXX
user SAP SAP
pwd
bye
BODY
when i run the script with function SXPG_COMMAND_EXECUTE and and command name Z_SH, return code is Not connected.#
The script can't login.
Anypone could help me.
Thanks and regards.
Eduardo Paiva

Hi Friend,
Can you check this link  will help you some extend : [FTP open file;
Regards,

Similar Messages

  • Run a shell script at login?

    I would like to run a simple shell script each time a user logs in. Currently, I have it wrapped in an Automator executable that is included in "Login Items", but figured there must be a more elegant way? Thanks.
    More info:
    The problem I'm trying to solve is that of file permissions when sharing one iTunes and one iPhoto library between multiple users on one computer. The libraries are located in /Users/Shared and the apps were pointed to the relocated libraries by holding down 'Option' on startup. The problem is that work done by each user in the iTunes or iPhoto library inherits the default permission settings of that user, making any new additions to the libraries, read-only to the other users. I'm using `chmod` on login to fix it. Let me know if you know of a better way to address this. Thanks again.

    I wrote a simple shell script that executes each time a user logs in (well, actually, each time I log in, coz' it's not really applicable to other users). It syncs my work and home addressbooks and iCal calendars to one another.
    I named it "sync". Then I read somewhere that if you wanted to make it double-clickable (to launch it from the Finder), I appended a ".command" filename extension (so it's now named "sync.command"). I also did a chmod 755 to that file so that it had execute privileges. Depending on whether you give each user their own copy of this thing, or keep a single copy in, say, the /Users/Shared directory, you may have to play around with chmod. Whatever, just so long as the user that has just logged in has execute permissions to the file, and to the entire path to the file, you should be good.
    Then, in SysPrefs > Accounts > Login Items, I added that "sync.command" file to the list. So, really the only difference is I'm not wrapping mine inside an Automator script like you are.
    I had tried adding it to ~/Library/LaunchAgents and make a launchd plist for it, that would kick it off at login. But I didn't get that to work. Don't know why. But just adding the double-clickable executable unix script to the Login Items list did the trick. Whether the plist has to hang out there with it, I don't know. I still have it there, though, in case I ever get motivated to figure out what's wrong with my launchd plist file. So, if just adding it to the Login Items list doesn't do it for you, you could try making a (functional?) launchd plist for it and plopping them both in ~/Library/LaunchAgents, too. That's how I am now, and, like I said, it launches at user login as that user's process (not as a root process like the above referenced article said how login hooks worked -- although, you may want it to run as root since you want this to work with multiple users...in which case, you might want to listen to Cole and not me...).

  • Shell script ftp

    Hi
    My ext 4tb (2x2TB raid 0) failed this week. HDD 2 failed to be more specific.
    Ive managed to get some functionality back but cant get into the file structure
    I was hoping to see if I could get in via shell script. Nopt used this before but given I could loose 3tb of movies and music I will try anything...
    Anyone have any gidance on using shell script to access an external network drive?
    I can ftp to the drive.
    Si

    Hi Friend,
    Can you check this link  will help you some extend : [FTP open file;
    Regards,

  • FTP Problem Shell Script

    Hi ..
    Every Month we are trying to send file to the user ..
    This is my shell script
    ftp -n <<EOF
    verbose on
    open 10.11.22.10
    user cg11118 fsetftp
    ascii
    cd
    put SHR.DE93C.ACCENT.GRP624FA 'SHR.DE93C.ACCENT.GRP624FA'
    bye
    Here is the Log file for the run
    ==========================Start FTP ======================
    Fri Feb 29 17:30:23 CST 2008
    Verbose mode on.
    Connected to 10.11.22.10
    220-FTPD1 IBM FTP CS V1R6 at VS04, 23:26:26 on 2008-02-29.
    220 Connection will close if idle for more than 60 minutes.
    Remote system type is MVS.
    331 Send password please.
    230 CG11118 is logged on. Working directory is "CG11118.".
    200 Representation type is Ascii NonPrint
    (remote-directory) 250 "CG11118.PUT." is the working directory name prefix.
    221 Quit command received. Goodbye.
    ==========================End FTP ========================
    everymonth we are having problem that file is not going ..
    my first question is
    1) how to know whether file is sent to the user or not ?
    2) is there any problem with the script
    can anyone help me in resolving this issue pls ..
    Thanks in advance
    Dev Kishore

    I have never found the ftp(1) program to be really useful in a batch environment. Usually a quick and dirty shell script just makes too many assumptions about what the other host is sending and unreliable operations result.
    Instead of using the stock ftp(1) tool, look into the curl(1) tool for this. It can send to any system supporting the FTP protocol (or using several other protocols as well) and is much easier to use in scripting. Curl(1) is designed for use in scripts, unlike the original ftp(1) tool.
    HTH

  • Ftp in unix shell script

    hi.
    I have the following requirement to be written as a shell script.
    1. ftp to another server ( say x)
    2. change the directory ( cd /data)
    3. check if there exists a file with extention .csv. If it does,
    3.1 get the file and copy it to a backup directory,
    3.2 rename the file to test.csv
    3.3 login to an oracle schema and execute a procedure.
    3.4. Based on the output, echo success or error
    3.5 If success delete the file
    Can all this be done in one script. ?
    Any help would be highly appreciated.
    Thanx

    Hi ,
    Hope the folllowing scipt listing will help you.
    cd /u01/backup/
    ftp -in << EOF
    open x
    cd data
    ls . /u01/backup/test.out
    EOF
    # Check whether .csv file exists.
    cat /u01/backup/test.out | awk '{print $9}' | tail +2 | cut -d "." -f 2 | grep csv
    if [ $? -eq 0 ]
    then
    cd /u01/backup/
    ftp -in << EOF
    open x
    cd data
    get
    EOF
    fi
    # renaming file
    cd /u01/backup/
    mv *.csv test.csv
    # set environment for database running
    export ORACLE_HOME=
    $ORACLE_HOME/sqlplus/bin -s /nolog << EOF > /dev/null
    connect user/pass
    spool output.lst
    @execute_the_script.sql
    spool off
    EOF
    ## procees output.lst and echo the result.
    ## Execute further steps..
    Regards,
    Aditya.

  • Do the shell script have to login into Oracle Apps

    I am calling the Document Processor Java API from a shell script. The problem I have that its unable to find the
    xdo://PO.POXPRPOLXMLRTF.en.US/?getSource=true
    file within the control file.
    Is this because somewhere a shell variable needs to be set, or a login need to be made into the Oracle Apps, so this template stored in XML Publisher is accessible.
    Please advise!

    Another things you can do is
    begin
    tmp_res := apps.fnd_web_sec.CHANGE_PASSWORD('TESTUSER','changeme',false);
    update fnd_user set password_date = null where user_name = 'TESTUSER'';
    end;
    Once you do this, when the TESTUSER logs in with the password=changeme, he/she will be redirected to the change password page.
    Hope this helps,
    Sandeep Gandhi

  • Shell Script- To FTP the latest file with the date stamp

    I have a Solaris 10 based system, where it generate some application files (multiple) in XML format and the file name comprises of the current date.
    File Format is as follows;
    CX-FIL-20070624000000-2-8452536d-000133.xml
    Where 20070624 repesents the curent date of the file
    I want to FTP these files to another server (Solaris 10 based Sun Machine) by comparing the file name with the current date.
    Please let me know how I can do this by using a shell script.

    Assuming you want to ftp the files with today's datestamp, you could match the files you want like so:
    CX-FIL-`/bin/date +"%Y%m%d"`*
    Use that in your script to generate the file list to be transferred...
    -Rob

  • FTP command in shell script

    Hello All,
    I would like to transfer a file from one system to another system.
    so i haven written shell script with ftp command as follows.
    ftp -i 10.14.12.1<< END
    cd C:\Temp
    put $datafile
    ascii
    quit
    But i am getting error.
    Please let me know the sysntax followed by me is correct or thar remote system is down,
    Many thanks,
    Kumar.

    The ftp(1) command is not well-suited for scripting. Instead us the curl(1) tool:
    curl -T myfile ftp://ftp.some.where/down/in/this/dir/
    for example.
    $ man 1 curl
    for more details.

  • FTP log file generation failed in shell script

    Hi ALL,
    I am doing FTP file transfer in shell script and able to FTP the files in to corresponding directory , But when i am trying to check the FTP status through the log files then its giving problem . please check the below code.
    for file in $FILENAME1
    do
    echo "FTP File......$file"
    echo 'FTP the file to AR1 down stream system'
    ret_val=`ftp -n> $file.log <<E
    #ret_val=`ftp -n << !
    open $ar1_server
    user $ar1_uname $ar1_pwd
    hash
    verbose
    cd /var/tmp
    put $file
    bye
    E`
    if [ -f $DATA_OUT/$file.log ]
    then
    grep -i "Transfer complete." $DATA_OUT/$file.log
    if [ $? -eq 0 ]; then
    #mv ${file.log} ${DATA_OUT}/../archive/$file.log.log_`date +"%m%d%y%H%M%S"`
    echo 'Log file archived to archive directory'
    #mv $file ${DATA_OUT}/../archive/$FILENAME1.log_`date +"%m%d%y%H%M%S"`
    echo 'Data file archived to archived directory'
    else
    echo 'FTP process is not successful'
    fi
    else
    echo 'log file generation failed'
    fi
    its giving syntax error end of file not giving the exact line number , please help me on thsi
    Regards
    Deb

    Thanks for ur reply
    Actually i did a mistake in the code i wrote the following piece of code below
    ret_val=`ftp -n> $file.log <<E
    #ret_val=`ftp -n << !
    so after the tilde symbol it as again taking the '# ' as a special character so it was giving error, so i removed the second line now its working fine.

  • Shell script login ssh

    Quick question with a quick answer, how can I make my shell script enter the login password to my remote server?
    Ex.
    #!/bin/sh
    ssh (user)@(ip here)
    (enter password)
    ...and so on...

    In addition to using keys. it would be advisable to limit what commands can be run using
    the key.
    see: sshd(8): under the "AUTHORIZED_KEYS FILE FORMAT" section.
    command="command"
    Specifies that the command is executed whenever this
    key is used for authentication. The command supplied
    by the user (if any) is ignored. The command is run on
    a pty if the client requests a pty; otherwise it is run
    without a tty. If an 8-bit clean channel is required,
    one must not request a pty or should specify no-pty. A
    quote may be included in the command by quoting it with
    a backslash. This option might be useful to restrict
    certain public keys to perform just a specific
    operation. An example might be a key that permits
    remote backups but nothing else. Note that the client
    may specify TCP/IP and/or X11 forwarding unless they
    are explicitly prohibited. Note that this option
    applies to shell, command or subsystem execution.

  • Help needed in shell script for FTPS

    Hi,
    Im trying to build a script to download files from a secure FTP site.
    When I run the command ftps <host_address> in the unix prompt, it asks username and password, and then prompts the following question.
    Do you want to trust this certificate? y(y):
    From the prompt, I am able to type 'y' and then it is connecting to the FTP site without any issue.
    When i run the shell script which contains the same command ftps <host_address>, it prompts the same question. And then it comes out of the program saying 'Connection aborted'.
    Could anyone tell me how to avoid this prompt?
    Thanks,
    Vidhya

    Ya. It worked for me when i typed the command ftps <host_address> in the command prompt.
    When I type this command, it is asking for username,pwd and after that, it is asking 'Do you want to trust this certificate?'. For this i have typed 'y' (Yes) in the command prompt.
    After i entered 'y', the connection got established properly.
    I have included this command in a shell script, and ran this script.
    When i execute the script, i asks 'Do you want to trust this certificate?'.
    Since i will not be able to type 'y'(Yes) connection is getting aborted.
    So, I want to know how to avoid this question ot how to enter 'y' while executing the script.
    Thanks

  • Secure login to remote UNIX host and run a shell script

    Hi I am new to JAVA. I want to login to remote UNIX host from my application secure login (SSH) and run a shell script reside that remote host. Can any one let me know the way how to do it. If possible provide the code example.

    Runtime.exec with an ssh command (not really recommended).
    Much better, an SSH API (JSch, which needs JZlib, from http://www.jcraft.com/ is a good one).

  • Running shell script at startup (before login)

    Objective: on the Mac side of a dual-boot Intel, I want to automate running a shell script at startup that will unmount the "Untitled" Windows partition. As a single line command, the following runs correctly when invoked manually from Terminal:
    /usr/sbin/diskutil unmount force disk0s3
    How can I include this script in the startup sequence?

    V.K. asks: "why do you need to do this before login?" And macwiz1220 suggests including in Login Items an app created by AppleScript that launches Terminal and runs the diskutil command.
    When I create and run such an app at login, I encounter problems with Terminal, which is why I thought to run an .sh script at startup. But if we can debug the problems with Terminal, then I won't have to venture into the more complex solutions offered by gbullman and Barney-15E. Terminal problems:
    (1) When Terminal prefs for Settings>Shell are set this way:
    (a) When the shell exits: Close the window.
    (b) Prompt before closing: Never
    then the result is: Terminal is launched and exits quickly, but the "Untitled" volume is not unmounted.
    (2) When Terminal prefs for Settings>Shell are set this way:
    (a) When the shell exits: Close the window if the shell exited cleanly
    (b) Prompt before closing: Never
    then again the result is: Terminal is launched and exits quickly, but the "Untitled" volume is not unmounted.
    (3) When Terminal prefs for Settings>Shell are set this way:
    (a) When the shell exits: Don't close the window
    (b) Prompt before closing: Always
    then after invoking the script, Terminal properly unmounts "Untitled" and presents a dialog: "You have 2 windows with running processes. Do you want to review these windows before quitting?" Here are the two Terminal windows:
    an echo of the cmd "/usr/sbin/diskutil unmount force disk0s3" followed by a report on return: "Volume on disk0s3 force unmounted." I don't want the user to have to see this and close the window.
    (ii) a fresh Terminal session, no commands entered. I also don't want the user to have to deal with this.
    How can I get Terminal to properly unmount the object, and shut down without demanding user interaction?
    P.S. what is an O.P.?

  • Why does Linux kill my shell script after I do an ftp or lftp?

    Hi,
    I've written a series of shell scripts that will log into a client site using ftp or lftp, get a data file , and then log out using quit and then EOF.
    The script excerpt is as follows.
    echo $PROGRAM_NAME - get
    lftp -u $USER,$PASSWORD $HOST <<EOF
    ls
    cd outbound
    ls
    quit
    EOF
    ### validate FTP                                                             ###
    echo $PROGRAM_NAME - validate
    if [ $? != 0 ];
         then
              echo "FAILURE - $FILE_NAME_DAT has failed FTP get." | mail -s "FAILURE - $PROGRAM_NAME" [email protected]
           exit 1
    fiSo from what I have, the output will show the first echo, the output from the lftp session, and then the scripts abruptly ends.
    It never makes to the second echo or for that matter the rest of the script. It just ends.
    The strange part is that I've compared it to scripts that are identical for what functions are being performed and yet the other scripts will continue on after the lftp.
    I've even brought it into MS Word and TextPad to look for hidden characters and they don't show any difference between script files with the error and script files with out it.
    Does anyone have any ideas?
    Thanks

    OK. This is the copy of the similar script that does work.
    I also added a set -vx to the other script.
    As you can see it's very similar in what it does like the other script, however this script puts the
    + lftp -u datamart,vagmr6o sftp://ftp.lowtruck.com...right after the lftp portion and not at the end of the script like the other script did.
    The script with out put is below.
    ### parameter $1 full PATH of the file to be staged                                                                                                    ###
    echo fhs_ftpget_lpmhmk.sh - parameters - $(date)
    date
    ++ date
    + echo fhs_ftpget_lpmhmk.sh - parameters - Thu Apr 14 15:13:36 CDT 2011
    fhs_ftpget_lpmhmk.sh - parameters - Thu Apr 14 15:13:36 CDT 2011
    PROGRAM_NAME=fhs_ftpget_lpmhmk.sh
    + PROGRAM_NAME=fhs_ftpget_lpmhmk.sh
    PRE_PROCESSING_DIRECTORY=/etl/datafeeds/pre_processing
    + PRE_PROCESSING_DIRECTORY=/etl/datafeeds/pre_processing
    PROCESSING_DIRECTORY=/etl/datafeeds/dev
    + PROCESSING_DIRECTORY=/etl/datafeeds/dev
    POST_PROCESSING_DIRECTORY=/etl/datafeeds/post_processing
    + POST_PROCESSING_DIRECTORY=/etl/datafeeds/post_processing
    POST_SOURCE_DIRECTORY=/etl/datafeeds/post_source
    + POST_SOURCE_DIRECTORY=/etl/datafeeds/post_source
    export HOST='sftp://ftp.lowtruck.net'
    + export HOST=sftp://ftp.lowtruck.net
    + HOST=sftp://ftp.lowtruck.net
    export USER='datamart'
    + export USER=datamart
    + USER=datamart
    export PASSWORD='vagmr6o'
    + export PASSWORD=vagmr6o
    + PASSWORD=vagmr6o
    export TEMP_DIRECTORY=/tmp
    + export TEMP_DIRECTORY=/tmp
    + TEMP_DIRECTORY=/tmp
    #export FILE_NAME_SOURCE=*1074691001.txt.gz
    FILE_NAME_GZ=LPMHMK1.gz
    + FILE_NAME_GZ=LPMHMK1.gz
    FILE_NAME_UNZIP=LPMHMK1
    + FILE_NAME_UNZIP=LPMHMK1
    FILE_NAME_DAT=LPMHMK1.dat
    + FILE_NAME_DAT=LPMHMK1.dat
    PASSPHRASE=focusedhs
    + PASSPHRASE=focusedhs
    ### Get File name                                                            ###
    export FILE_NAME_SOURCE=`/home/fhs_clientdata/ftpget/fhs_ftpget_lpmhmk1_get_latest_file.sh| awk '{IGNORECASE=1}/txt.gz/&&!/test/&&!/err/{print $9}'|tail -1`
    /home/fhs_clientdata/ftpget/fhs_ftpget_lpmhmk1_get_latest_file.sh| awk '{IGNORECASE=1}/txt.gz/&&!/test/&&!/err/{print $9}'|tail -1
    ++ /home/fhs_clientdata/ftpget/fhs_ftpget_lpmhmk1_get_latest_file.sh
    ++ awk '{IGNORECASE=1}/txt.gz/&&!/test/&&!/err/{print $9}'
    ++ tail -1
    + export FILE_NAME_SOURCE=20110413_1074691001.txt.gz
    + FILE_NAME_SOURCE=20110413_1074691001.txt.gz
    ### get FTP                                                                  ###
    echo $PROGRAM_NAME - get
    + echo fhs_ftpget_lpmhmk.sh - get
    fhs_ftpget_lpmhmk.sh - get
    lftp -u $USER,$PASSWORD $HOST <<EOF
    ls
    cd medical
    #get -E $FILE_NAME_SOURCE -o $TEMP_DIRECTORY/$FILE_NAME_GZ
    #rm $FILE_NAME_SOURCE can't be used with lftp. The -E in the get command does the same thing.
    quit
    EOF
    + lftp -u datamart,vagmr6o sftp://ftp.lowtruck.com
    drwxr-sr-x   1 40769    2001         4096 Nov 22 10:09 .
    drwxr-sr-x   1 40769    2001         4096 Nov 22 10:09 ..
    drwxr-s---   1 1999     2001         8192 Apr 12 02:02 medical
    ### validate FTP                                                             ###
    echo $PROGRAM_NAME - validate
    + echo fhs_ftpget_lpmhmk.sh - validate
    fhs_ftpget_lpmhmk.sh - validate
    if [ $? != 0 ];
            then
                    echo "FAILURE - $FILE_NAME_DAT has failed FTP get." | mail -s "FAILURE - $PROGRAM_NAME" [email protected]
            exit 1
    fi
    + '[' 0 '!=' 0 ']'
    ### Unzip                                                                    ###
    echo $PROGRAM_NAME - unzip
    + echo fhs_ftpget_lpmhmk.sh - unzip
    fhs_ftpget_lpmhmk.sh - unzip
    # Preserving unzipped copy because gunzip doesn't leave the original file after the unzip.
    #cp -f $TEMP_DIRECTORY/$FILE_NAME_GZ $POST_SOURCE_DIRECTORY
    #gunzip $TEMP_DIRECTORY/$FILE_NAME_GZ
    #gunzip is incapable of directly renaming files that it unzips,
    #so the rename will happen when the file is moved in the next segment.
    ### move unzipped file from FTP_DIRECTORY to PRE_PROCESSING_DIRECTORY        ###
    echo $PROGRAM_NAME - move
    + echo fhs_ftpget_lpmhmk.sh - move
    fhs_ftpget_lpmhmk.sh - move
    #mv -f $TEMP_DIRECTORY/$FILE_NAME_UNZIP $PRE_PROCESSING_DIRECTORY/$FILE_NAME_DAT
    ### exit                                                                     ###
    echo $PROGRAM_NAME - exit
    + echo fhs_ftpget_lpmhmk.sh - exit
    fhs_ftpget_lpmhmk.sh - exit
    exit 0
    + exit 0So when you compare the two scripts, I honestly can't see what the difference is or what I'd have to do in order to fix this.
    Do you have any ideas?
    Thanks,

  • Shell script to send concurrent program output via FTP and Email

    Hi,
    Does any one have a shell script to send the output generated by a concurrent proram
    1 - Using FTP to an external server
    2 - By email as an attachment.
    Thanks

    There are more specific forums which address this question within the Oracle Technology Network. Please consider posting your question there for better responses. The focus of this forum is limited to HRMS suite of modules:
    http://forums.oracle.com/forums/categoryHome.jspa?categoryID=84
    Regards,
    Greg

Maybe you are looking for