I am trying to create a directory with current date (like BK-date +"%d%m%Y-%H%M" ) in ftp remote site using LFTP mkdir command, but I am unable to create.
please provide some suggestions how I can able to achieve this.
Example:
mkdir -p /backup/BK-date +"%d%m%Y-%H%M"
You can use “source -e date +‘mkdir %…’”
Related
I'm trying to create what I thought would be a simple .bat file to login to a Unix server and cd/dir but I can't seem to get it to do anything past the initial login. What I've tried so far:
#echo off
putty -load "servername" -l username -pw pass
echo cd /usr/frank/ftp/bin
Also tried creating a separate file to be called for the chdir but it's not calling the other file either.
-m C:\Users\Userzed\Desktop\ftp.txt
echo cd /usr/frank/ftp/bin
I appreciate any help to show me why this isn't working or point me to where I'm messing this up.
I am not sure if this could be remedied by Programming means but I had a MailX shell script that was working properly in the test server. But when I run the script in the production server, the recipient only receives a file named 'eml' that can't be even opened. I was informed by the system administrator that the configurations of both servers are the same and I should be adjusting my code.
But I used the exact same shell script and it works in the test server.
cd /home/guava/autoemail
datediff=1
datetoday=$(date +%Y%m%d)
foldername=$(date --date="${datetoday} -${datediff} day" +%Y%m%d)
mv DEALS_ENTERED_TODAY_ALL_2OM_UP.xls DEALS_ENTERED_TODAY_ALL_2OM_UP_$foldername.xls
zip -P $foldername DEALS_ENTERED_TODAY_ALL_2OM_UP_$foldername.zip DEALS_ENTERED_TODAY_ALL_2OM_UP_$foldername.xls
cat /home/guava/autoemail/email_body.txt | mailx -s "AML_20M_DAILY_TRANSACTION_REPORT_GUAVA_$foldername" -a /home/guava/autoemail/DEALS_ENTERED_TODAY_ALL_2OM_UP_$foldername.zip ben#onionwank.com
rm DEALS_ENTERED_TODAY_ALL_2OM_UP_$foldername.xls
rm DEALS_ENTERED_TODAY_ALL_2OM_UP_$foldername.zip
what it does:
-declares the date yesterday
-renames an excel file with the yesterday's date
-zip the excel file with a password
-email it to the user
-delete the used files.
I just want to ask if there is anything I can improve with my code so I can use it in the production server. Why does the server send an 'eml' file instead of the attachment I defined?
It is possible that this is a server issue but the system admins don't seem to know what to do.
I have written a Shell script that moves into a directory with some binaries files present.
What I am looking to do is transfer all the files present inside this directory.
cd /home/user/binaries
smbclient //ip.address/directory$ password -W domain -U username << ENDOFMYSMBCOMMANDS
prompt
put *
exit
ENDOFMYSMBCOMMANDS
I tried to use put * to transfer all files - but this is not accepted.
The only other option I know of is to go one folder up, and use the command mput binaries - but this copies everything including the folder.
How can I modify my script to only transfer the contents of the directory?
I'm going to format the self-answer of Dustin a bit differently into a real one-liner. It is also possible to add the prepended "cd" command into the smbclient command, like so:
smbclient //ip.address/directory -W domain -U username \
-c 'prompt OFF; recurse ON; cd remote/target/directory; lcd /local/source/directory; mput *'
I had the answer with me all along!! I was under the impression that mput could only be used to transfer a directory, turns out that using mput * inside a directory will copy all the files located within that directory!
cd /home/user/binaries
smbclient //ip.address/directory$ password -W domain -U username << ENDOFMYSMBCOMMANDS
prompt
put *
exit
ENDOFMYSMBCOMMANDS
Going to leave this here for anyone else who gets stumped on this like me!
I'm currently using Sikuli to upload a PDF file to a website server. This seems inefficient. Ideally I would like to run a shell script and get it to upload this file on a certain day/time (i.e Sunday at 5AM) without the use of Sikuli.
I'm currently running Mac OS Yosemite 10.10.1 and the FileZilla FTP Client.
Any help is greatly appreciated, thank you!
Create a bash file like this (replace all [variables] with actual values):
#!/bin/sh
cd [source directory]
ftp -n [destination host]<<END
user [user] [password]
put [source file]
quit
END
Name it something like upload_pdf_to_server.sh
Make sure it has right permission to be executed:
chmod +x upload_pdf_to_server.sh
Set a cron job based on your need to execute the file periodically using command crontab -e
0 5 * * * /path/to/script/upload_pdf_to_server.sh >/dev/null 2>&1
(This one will execute the bash file every day at 5AM)
How to set cronjob
Cronjob generator
Tried doing this:
ftp -nvd server01 <<- END
user user01 password123
mkdir -p /dirA/dirB/dirC/dirD/
expected result:
/dirA/dirB/dirC/dirD/ should be created in server01
actual result:
-p directory is created in home directory of server01
The problem is "-p" is treated as the directory name instead of an option for mkdir command.
Thanks in advance.
The dumb ftp client does not support -p as an option argument to mkdir, but if you require this feature you can use another client which does, e.g. lftp.