Sponsored Content
Full Discussion: Rsync and Move files
Top Forums Shell Programming and Scripting Rsync and Move files Post 303016658 by James0806 on Tuesday 1st of May 2018 05:23:14 PM
Old 05-01-2018
Code:
#bin/bash -x
source1="/home/u02/Oracle"
dest1="/home/u02/Oracle/LOG"
chmod 777  $source1/*.tif
chmod 777  $source1/*.txt
/usr/bin/scp  $source1/*.tif  192.168.83.7:/mnt/dbfs/
 if [ $? -eq 0 ]
        then
         echo " files were copied with extension tif on `date`" >> /var/log/croncopy.txt
        fi
/usr/bin/scp  $source1/*.txt  10.83.83.7:/mnt/dbfs/
 if [ $? -eq 0 ]
        then
         echo " files were copied with extension txt on `date`" >> /var/log/croncopy.txt
        fi
/usr/bin/scp  $source1/*.TIF  10.83.83.7:/mnt/dbfs/
 if [ $? -eq 0 ]
        then
         echo " files were copied with extension TIF on `date`" >> /var/log/croncopy.txt
        fi

exit

---------- Post updated at 02:52 AM ---------- Previous update was at 02:51 AM ----------

Code:
#!/bin/bash
source1="/home/u02/Oracle"
dest1="/home/u02/Oracle/LOG"
dirdatelog=`date +%Y%m%d%H%M%S`
mkdir $dest1/$dirdatelog
movedest="$dest1/$dirdatelog/"
mv $source1/*.tif $movedest > /dev/null 2>>/var/log/errormove.txt
mv $source1/*.txt $movedest  > /dev/null 2>>/var/log/errormove.txt
mv $source1/*.TIF $movedest  > /dev/null 2>>/var/log/errormove.txt
exit

---------- Post updated at 02:53 AM ---------- Previous update was at 02:52 AM ----------

The two above scripts will copy initially and later move the files to the destination folder
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

rsync, which files where moved?

Hello, I am using rsync to make sure that my folder "local" mirrors the remote directory "remote". When a file is copied from "remote" to "local", I need to apply a bash script to it. What would be a neat way to do that? Thanks ps: is there a way to edit the title of the thread (I am a bit... (5 Replies)
Discussion started by: JCR
5 Replies

2. Shell Programming and Scripting

Bash rsync but move not delete

There might be an easy solution to my problem, or maybe not, but here it is. I am trying to rsync a Volume with 1.5 terabytes of data and send it via fibre channel to a raid array. Now normally when I rsync it scans through everything and, before copying anything, deletes any files that have... (1 Reply)
Discussion started by: Movomito
1 Replies

3. Shell Programming and Scripting

How to check files and move the results to differents files?

Hi, I am a newbie to shell scripting. here is my objective: 1)The shell program should take 2 parameters - ie-> DestinationFolder, WebFolder 2)Destination folder contains few files that has to has be verified and deleted. 3)WebFolder is a folder containing a list of master files 4)It... (1 Reply)
Discussion started by: sandhyagupta
1 Replies

4. UNIX for Dummies Questions & Answers

Move same files and issue ls -al command on remaining files

I know I can use an ls -l junk1 command to get a listing of all files in the directory junk1, but I was wondering how I'd go about going through the files in junk1 in a for-in loop and issuing the ls -l command on them one by one. This is what I have so far: for file in $(ls -a $1) do ls... (1 Reply)
Discussion started by: Trinimini
1 Replies

5. Shell Programming and Scripting

Recursively move directories along with files/specific files

I would like to transfer all files ending with .log from /tmp and to /tmp/archive (using find ) The directory structure looks like :- /tmp a.log b.log c.log /abcd d.log e.log When I tried the following command , it movies all the log files... (8 Replies)
Discussion started by: frintocf
8 Replies

6. Shell Programming and Scripting

Move all files except sys date (today) files in Solaris 10

I want to move all files from one directory to another directory excluding today (sysdate files) on daily basis. file name is in pattern file_2013031801, file_2013031802 etc (2 Replies)
Discussion started by: khattak
2 Replies

7. Shell Programming and Scripting

Rsync move with symlinks

Hi, I use rsync to move from source to target, but there are cases that I need to exclude: Suppose in my file system, I have a soft link ~/data -> /media/volgrp/data. Under data folder, there is a file hello.txt. After moving command "rsync --remove-source-files -aH --force ~/data/... (3 Replies)
Discussion started by: huangyingw
3 Replies

8. Shell Programming and Scripting

SBATCH trinity for multiple files and rename/move the output files

Hey guys, I have wrote the following script to apply a module named "trinity" on my files. (it takes two input files and spit a trinity.fasta as output) #!/bin/bash -l #SBATCH -p node #SBATCH -A <projectID> #SBATCH -n 16 #SBATCH -t 7-00:00:00 #SBATCH --mem=128GB #SBATCH --mail-type=ALL... (1 Reply)
Discussion started by: @man
1 Replies

9. UNIX for Beginners Questions & Answers

Move directory with rsync and delete from source

I need a rsync command which will exclude certain files and directories from source and copy the rest. I got this command working, sudo rsync -avzh --exclude 'bin' --exclude 'braintree' --exclude 'colinmollenhour' --exclude 'composer' --exclude 'doctrine' --exclude 'fabpot' --exclude... (2 Replies)
Discussion started by: Siddheshk
2 Replies

10. Shell Programming and Scripting

Move files with a certain suffix based on how many files are in another folder

Hello, First time poster. I am looking for a way to script or program the process of moving files from one folder to another, automatically, based on the count of files in the destination folder. I was thinking a shell script would work, but am open to the suggestions of the experts... (6 Replies)
Discussion started by: comtech
6 Replies
lshell(1)						      General Commands Manual							 lshell(1)

NAME
lshell - Limited Shell SYNOPSIS
lshell [OPTIONS] DESCRIPTION
lshell provides a limited shell configured per user. The configuration is done quite simply using a configuration file. Coupled with ssh's authorized_keys or with /etc/shells and /etc/passwd , it becomes very easy to restrict user's access to a limited set of command. OPTIONS
--config <FILE> Specify config file --log <DIR> Specify the log directory -h, --help Show help message --version Show version CONFIGURATION
You can configure lshell through its configuration file: On Linux -> /etc/lshell.conf On *BSD -> /usr/{pkg,local}/etc/lshell.conf lshell configuration has 4 types of sections: [global] -> lshell system configuration (only 1) [default] -> lshell default user configuration (only 1) [foo] -> UNIX username "foo" specific configuration [grp:bar] -> UNIX groupname "bar" specific configuration Order of priority when loading preferences is the following: 1- User configuration 2- Group configuration 3- Default configuration [global] logpath config path (default is /var/log/lshell/) loglevel 0, 1, 2, 3 or 4 (0: no logs -> 4: logs everything) logfilename - set to syslog in order to log to syslog - set log file name, e.g. %u-%y%m%d (i.e foo-20091009.log): %u -> username %d -> day [1..31] %m -> month [1..12] %y -> year [00..99] %h -> time [00:00..23:59] syslogname in case you are using syslog, set your logname (default: lshell) [default] and/or [username] and/or [grp:groupname] aliases command aliases list (similar to bash's alias directive) allowed a list of the allowed commands or set to 'all' to allow all commands in user's PATH allowed_cmd_path a list of path; all executable files inside these path will be allowed env_path update the environment variable $PATH of the user (optional) env_vars set environment variables (optional) forbidden a list of forbidden characters or commands history_file set the history filename. A wildcard can be used: %u -> username (e.g. '/home/%u/.lhistory') history_size set the maximum size (in lines) of the history file home_path (deprecated) set the home folder of your user. If not specified, the home directory is set to the $HOME environment variable. This variable will be removed in the next version of lshell, please use your system's tools to set a user's home directory. A wildcard can be used: %u -> username (e.g. '/home/%u') intro set the introduction to print at login passwd password of specific user (default is empty) path list of path to restrict the user geographically. It is possible to use wildcards (e.g. '/var/log/ap*'). prompt set the user's prompt format (default: username) %u -> username %h -> hostname prompt_short set sort prompt current directory update - set to 1 or 0 overssh list of command allowed to execute over ssh (e.g. rsync, rdiff- backup, scp, etc.) scp allow or forbid the use of scp connection - set to 1 or 0 scpforce force files sent through scp to a specific directory scp_download set to 0 to forbid scp downloads (default is 1) scp_upload set to 0 to forbid scp uploads (default is 1) sftp allow or forbid the use of sftp connection - set to 1 or 0 sudo_commands a list of the allowed commands that can be used with sudo(8) timer a value in seconds for the session timer strict logging strictness. If set to 1, any unknown command is considered as forbidden, and user's warning counter is decreased. If set to 0, command is considered as unknown, and user is only warned (i.e. *** unknown synthax) warning_counter number of warnings when user enters a forbidden value before getting exited from lshell. Set to -1 to disable the counter, and just warn the user. SHELL BUILTIN COMMANDS
Here is the set of commands that are always available with lshell: clear clears the terminal help, ? print the list of allowed commands history print the commands history lpath lists all allowed and forbidden path lsudo lists all sudo allowed commands EXAMPLES
$ lshell Tries to run lshell using default ${PREFIX}/etc/lshell.conf as configuration file. If it fails a warning is printed and lshell is interrupted. lshell options are loaded from the configuration file $ lshell --config /path/to/myconf.file --log /path/to/mylog.log This will override the default options specified for configuration and/or log file USE CASE
The primary goal of lshell, was to be able to create shell accounts with ssh access and restrict their environment to a couple a needed commands. In this example, User 'foo' and user 'bar' both belong to the 'users' UNIX group: User foo: - must be able to access /usr and /var but not /usr/local - user all command in his PATH but 'su' - has a warning counter set to 5 - has his home path set to '/home/users' User bar: - must be able to access /etc and /usr but not /usr/local - is allowed default commands plus 'ping' minus 'ls' - strictness is set to 1 (meaning he is not allowed to type an unknown command) In this case, my configuration file will look something like this: # CONFIURATION START [global] logpath : /var/log/lshell/ loglevel : 2 [default] allowed : ['ls','pwd'] forbidden : [';', '&', '|'] warning_counter : 2 timer : 0 path : ['/etc', '/usr'] env_path : ':/sbin:/usr/bin/' scp : 1 # or 0 sftp : 1 # or 0 overssh : ['rsync','ls'] aliases : {'ls':'ls --color=auto','ll':'ls -l'} [grp:users] warning_counter : 5 overssh : - ['ls'] [foo] allowed : 'all' - ['su'] path : ['/var', '/usr'] - ['/usr/local'] home_path : '/home/users' [bar] allowed : + ['ping'] - ['ls'] path : - ['/usr/local'] strict : 1 scpforce : '/home/bar/uploads/' # CONFIURATION END NOTES
In order to log a user's warnings into the logging directory (default /var/log/lshell/) , you must firt create the folder (if it doesn't exist yet) and chown it to lshell group: # addgroup --system lshell # mkdir /var/log/lshell # chown :lshell /var/log/lshell # chmod 770 /var/log/lshell then add the user to the lshell group: # usermod -aG lshell user_name In order to set lshell as default shell for a user: On Linux: # chsh -s /usr/bin/lshell user_name On *BSD: # chsh -s /usr/{pkg,local}/bin/lshell user_name AUTHOR
Currently maintained by Ignace Mouzannar (ghantoos) EMAIL
Feel free to send me your recommendations at <ghantoos@ghantoos.org> v0.9.15 March 13, 2012 lshell(1)
All times are GMT -4. The time now is 03:55 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy