Make FTP script to upload file to server?
I have OpenSuSE 11.2, and I have a script to download the latest version of our family's schedule [we sing and travel around the country part of the year]:
Code:
cd /home/matthew/Desktop/local/ If possible I would like a little prompt after closing CompoZer, Code:
upload schedule.html? y/n So, can you show me what I need to paste at the end of my script, to log in to ftp and upload schedule.html, after closing KompoZer?? Thanks so much!! |
Not tested, but something like this:
Quote:
|
I tried it, but it said something like it could not find the file/folder. I suspect because it was looking for "/home/matthew/Desktop/local/" under my /htdocs dir. So I took out the $username, $password, etc, and just put it in directly, and I used lcd to change the local dir to ~/Desktop/local/, and then it was able to find schedule.html and upload it!! Thanks for your help! I now have an alias to the script [sh ~/Desktop/local/upload_schedule] so I can quickly download it and upload it [I have a download alias too]. But, it would be cooler, and quicker, if at the end of my download script, I could have a prompt: "Upload also? Y/N" where, "y" would in turn run the upload script. Do you know if it's possible? Thanks :)
~Matt |
Try this;
Code:
#!/bin/bash |
Thanks Dave!! It works! Updating the schedule will be a lot easier now. =)
One more thing, could you sort of explain a little about, what it means? Obviously I can get that if I say "y,Y,YES,yes,Yes" then it will jump to ";;" and run everything after that, bypassing the 'exit.' and what does 'esac' mean? 'read'? 'case'? If you don't have time, that's perfectly fine. I was just wondering. ~Matt |
What we are saying;
We keep doing everything between while true do .... done WHILST true is true. True will always be true, so this would loop forever. We are saying 'keep doing this until we get an answer we want'. Whilst in this loop we read the stdin (keyboard) into the variable CONFIRM and then check to see if it matches any of these patterns: y or Y or YES or yes or Yes - if it does we 'break' out of the while/do and the script continues after the 'done' statement (which closes the while do). If not we check to see if it matches any of the (default) patterns: n or N or no or NO or No - if it does we exit the program with the 'exit' command. If nothing matches we go back to reading the the stdin (keyboard) as true is still (and will always be) true. The y or Y or YES or yes or Yes and n or N or no or NO or No is just to cover the various bases that a user may type instead of y or n. Users are odd like that. We've covered the block: while true do .... done Your other question is about the CASE or 'switch' statement, basically this checks a variable against a list of cases. Here there are two - but one is the default 'catch all' (hence no break;; terminating it). The closing of case is easc (it's almost case backward). Truth is, I'm no whizz with bash scripting. I keep a copy of everything useful I do, and the FTP and Y/N are common for me. Take a look at this - it has some more meat ;-) http://www.linuxquestions.org/questi...script-637221/ |
All times are GMT -5. The time now is 05:11 PM. |