LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-05-2015, 09:36 AM   #1
kuriyo
LQ Newbie
 
Registered: Jan 2015
Posts: 4

Rep: Reputation: Disabled
Shell script


could you please give a help on writing a shell script that will move from folder1 to folder2 on an houlry basis and re_name the folders into folder2 as "%Y%m%d%hh24"`
 
Old 01-05-2015, 09:41 AM   #2
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7
Posts: 3,474

Rep: Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553
What have you written so far?
 
Old 01-05-2015, 10:05 AM   #3
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,622

Rep: Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964
Quote:
Originally Posted by kuriyo View Post
could you please give a help on writing a shell script that will move from folder1 to folder2 on an houlry basis and re_name the folders into folder2 as "%Y%m%d%hh24"`
Please see the "LQ Question Guidelines" link in my posting signature.

We will be happy to HELP you with a script, but we are not going to write it for you. There are MANY THOUSANDS of bash scripting tutorials you can find with a brief Google search. If you post what you have written yourself and tell us what you're stuck on/confused about, we will be happy to assist.
 
Old 01-05-2015, 10:14 AM   #4
kuriyo
LQ Newbie
 
Registered: Jan 2015
Posts: 4

Original Poster
Rep: Reputation: Disabled
#/bin/sh

cd
. ./.profile

cd /baksett/media/orgdata/backup

today_hour=`date +"%Y%m%d%k"`

mkdir $today_hour

mv b*.dat /baksett/media/orgdata/backup/$today_hour

cd /baksett/media/orgdata/backup/$today_hour

ftp -ni 10.20.0.18 <<EOF
user lio test
binary
mput b*.dat
quit
EOF

>>>i got nothing for now
 
Old 01-05-2015, 10:17 AM   #5
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7
Posts: 3,474

Rep: Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553
Quote:
Originally Posted by kuriyo View Post
Code:
#/bin/sh

cd
. ./.profile

cd /baksett/media/orgdata/backup

today_hour=`date +"%Y%m%d%k"`

mkdir $today_hour

mv b*.dat /baksett/media/orgdata/backup/$today_hour

cd /baksett/media/orgdata/backup/$today_hour

ftp -ni 10.20.0.18 <<EOF
user lio test
binary
mput b*.dat
quit
EOF
>>>i got nothing for now
Nothing where? In the newly created folder or at the ftp side?


Try adding set -x as the second line of your script and then run it, that'll let you see each line as it's being processed, you may get a clue.
 
1 members found this post helpful.
Old 01-05-2015, 11:26 AM   #6
kuriyo
LQ Newbie
 
Registered: Jan 2015
Posts: 4

Original Poster
Rep: Reputation: Disabled
in the newly created folder
 
Old 01-05-2015, 05:57 PM   #7
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Note using "%k" almost never makes sense (while "%H" does) and since you 'mv' files instead of using 'cp' there may be nothing left to move?..
To see what a script and subsequent commands actually do execute in verbose mode:

Code:
#/bin/bash -vx
TIMESTAMP=$(/bin/date +"%Y%m%d_%H")
cd
. ~/.profile
cd /baksett/media/orgdata/backup
mkdir "${TIMESTAMP}"
/bin/mv -v b*.dat "/baksett/media/orgdata/backup/${TIMESTAMP}"
cd "/baksett/media/orgdata/backup/${TIMESTAMP}"
ftp verbose -ni 10.20.0.18 <<EOF
user lio test
binary
mput b*.dat
quit
EOF

exit 0
and check the output. If unsure post everything [code]and between BB tags[/code].
 
Old 01-06-2015, 07:46 AM   #8
kuriyo
LQ Newbie
 
Registered: Jan 2015
Posts: 4

Original Poster
Rep: Reputation: Disabled
i tried to put event the tags and i still don't get an ouput
Thx
 
Old 01-06-2015, 12:30 PM   #9
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
We can't read minds nor look at your terminal window: post complete output and between BB code tags.
 
Old 01-06-2015, 09:08 PM   #10
igadoter
Senior Member
 
Registered: Sep 2006
Location: wroclaw, poland
Distribution: many, primary Slackware
Posts: 2,717
Blog Entries: 1

Rep: Reputation: 625Reputation: 625Reputation: 625Reputation: 625Reputation: 625Reputation: 625
I would try ftp command on local host. For testing
Code:
ftp ni localhost << EOF ..
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Shell script for run an shell script on server using ssh bloodstreetboy Linux - Server 5 01-12-2013 03:23 AM
How to pass command line arguments from one shell script to another shell script VijayaRaghavanLakshman Linux - Newbie 5 01-20-2012 09:12 PM
Executing a Shell script with 654 permissions inside another shell script. changusee2k Linux - Newbie 2 06-07-2011 07:58 PM
shell script problem, want to use shell script auto update IP~! singying304 Programming 4 11-29-2005 05:32 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:59 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration