LinuxQuestions.org
Review your favorite Linux distribution.
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, 10: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, 10:41 AM   #2
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7
Posts: 2,166

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

Rep: Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693
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, 11: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, 11:17 AM   #5
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7
Posts: 2,166

Rep: Reputation: 751Reputation: 751Reputation: 751Reputation: 751Reputation: 751Reputation: 751Reputation: 751
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, 12:26 PM   #6
kuriyo
LQ Newbie
 
Registered: Jan 2015
Posts: 4

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

Rep: Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530
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, 08: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, 01:30 PM   #9
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,331
Blog Entries: 55

Rep: Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530
We can't read minds nor look at your terminal window: post complete output and between BB code tags.
 
Old 01-06-2015, 10:08 PM   #10
igadoter
Member
 
Registered: Sep 2006
Location: wroclaw, poland
Distribution: slackware 12.2, scientific linux 6.4, knoppix 7.2, salix 14.1
Posts: 854

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


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 04:23 AM
How to pass command line arguments from one shell script to another shell script VijayaRaghavanLakshman Linux - Newbie 5 01-20-2012 10:12 PM
Executing a Shell script with 654 permissions inside another shell script. changusee2k Linux - Newbie 2 06-07-2011 08:58 PM
shell script problem, want to use shell script auto update IP~! singying304 Programming 4 11-29-2005 06:32 PM


All times are GMT -5. The time now is 07:05 AM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration