Go Back   vb.org Archive > Community Central > Community Lounge
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 02-16-2007, 09:29 PM
TruthElixirX's Avatar
TruthElixirX TruthElixirX is offline
 
Join Date: Sep 2004
Location: Oklahoma
Posts: 517
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Multiple Folders - One File (FTP Q)

I have one fill I need to push to every folder inside of this one directory (100+ folders.) Anyway to write some sort of command to make it do it automatically, instead of moving each one hand?

Maybe a separate program?

So basically looks like this:

www>directory1> 100 + folders

and I need to put this one file in everyone one of those folders.
Reply With Quote
  #2  
Old 02-18-2007, 07:06 PM
TruthElixirX's Avatar
TruthElixirX TruthElixirX is offline
 
Join Date: Sep 2004
Location: Oklahoma
Posts: 517
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Code:
#! /bin/sh
# Joe was here
# 10/25/2003
# Script : Copy 1 file to multiple users folders
#
# Reset Copy Counter
x=0
# Prompt for Filename and Location
echo -n "Source Filename and Location [/folder/filename.txt]: "
# Take input make it a string
read P
# If no input the take default source location
if [ "$P" = "" ]; then
P="/folder/filename.txt"
fi
# Filter Filename from $P and make a new string $N
N=`basename $P`
# Prompt for /Users/ folder location
echo -n "Where is your users folder [/Users/]: "
# Take input make it a string
read D
# If no input the take default user location
if [ "$D" = "" ]; then
G="/Users/"
D="/Users/*"
# if input then add to input /* to the end of user location
# adding /* makes a wildcard "any folder" in /user/ 
else
D=$G
D="$D/*"
fi
#
# Prompt for the destination folder 
echo -n "Where will this file be saved [/Library/Preferences/]: "
# Take input make it a string 
read L
# If no input the take default user location
if [ "$L" = "" ]; then
L="/Library/Preferences/"
fi
#
# Create Indeterminate Loop
for F in $D 
do
# Take Username from $F string 
U=`basename $F`
#
# Only if Directories is present filter
if [ -d $F ]
then
#
# copy $P to $F$L if no file exists -i prompts user for over write
# $P = Source file $F = user path 
cp -i $P $F$L
# File Copy Counter
x=`expr $x + 1`
#
# Set Owner and Group to file
# $U = user , staff = group , change group as needed
chown $U:staff $F$L$N
#
# Set File Permissions 
# 744 = 7 User: read-write-execute
#     = 4 Group: read 
#     = 4 Everyone: read
# Read = 4 , Execute = 1 , Write = 2 ,
# None = 0 , So Read+Execute+Write = 7 , Read = 4
# Set Permissions to file:
# User Read Write Execute ( rwx ) , 
# Group Read (r) , Everyone Read (r) 
chmod 744 $F$L$N
#
fi
# 
# End Loop
done
# Print Total Copied Files
echo
echo File copied $x times
echo
echo Creating Log File
echo
echo Writing to List.txt
# finds all files copied in $G | filters files with $N
# then writes file locations to List.txt
find $G -print | grep $N > List.txt
#
# Copy List.txt to Desktop
cp List.txt ~/Desktop/
# Launches TextEdit.app and opens List.txt
open ~/Desktop/List.txt
echo
echo Done
echo Enjoy
Someone gave me this, but I don't quite understand it.

I run this in a SSH client, right? like PuTTY?


Ugh, I'm a bit confused. I'm not sure what to do.

I have a robots.txt on my desktop and need to put it in everyone of the folders underneath /html/ (Yes, I'm aware this isn't how robots.txt is supposed to be used. Don't ask. -_-...)

I tried running the script, but I'm quite a n00b at SSH.
Reply With Quote
  #3  
Old 02-22-2007, 07:20 PM
magnus's Avatar
magnus magnus is offline
 
Join Date: Apr 2002
Location: Miami, FL
Posts: 1,107
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

It's bash script. Upload it to your server then SSH (or telnet) in. Run either of the following commands:

Quote:
$ chmod +x <script>
$ ./<script>
OR

Quote:
$ sh <script>
Reply With Quote
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 On
HTML code is Off

Forum Jump


All times are GMT. The time now is 07:33 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.03373 seconds
  • Memory Usage 2,180KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_code
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (3)post_thanks_box
  • (3)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (3)post_thanks_postbit_info
  • (3)postbit
  • (3)postbit_onlinestatus
  • (3)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete