Borzoi 24 Posting Whiz

I believe that prash21m is trying to get search results returned even if the search query contains something not in the description.

I haven't done anything like this for a while so there may be a more efficient way to do this but what I did when I needed to do something like this is convert the input string in to an array then loop through that array, expanding the SQL qeury with OR statements. Note that the below is from memory.

$search = $_POST["search"]; //Your variables may be different.

$searcharr = explode(" ",$search); //This converts the search string into an array, using the spaces as delimiters.

$sql = "SELECT * FROM table_name WHERE description LIKE %".$searcharr[0]."% "; //This starts the SQL query and inputs the first entry of the array.

for ($i = 1; isset($searcharr[$i]; $i++) //This will continue to loop as long as there is another word/entry in the string.
{
    $sql .= "OR description LIKE %".$searcharr[$i]."% "; // This will append the SQL query. Note the period in front of the equals.
}

$sql .= ";"; //This closes off the SQL query.

You then run the SQL query as normal.

With this code, you search the database per word instead of the whole string. The conversion to an array from a string will convert this:

20% off on all product and clothes

To this:

Array
{
    [0] = 20%
    [1] = off
    [2] = on
    [3] = all
    [4] = product
    [5] = and
    [6] = clothes
}
Borzoi 24 Posting Whiz

If that has solved your problem, make sure you mark the thread as solved so that others who may have a similar problem can find the solution easier.

Borzoi 24 Posting Whiz

The way you're passing information into the $url variable wouldn't work. Using the Previous link, your if statement is this:

if ($screen > 0) {
$url = "z.php?screen=" . $screen - 1;
echo "<a href=\"$url\">Previous</a>\n";
}

You'll want to pass the value of $screen - 1 into a different variable which you then pass into $url like this:

if ($screen > 0) {
$previous = $screen - 1;
$url = "z.php?screen=" . $previous;
echo "<a href=\"$url\">Previous</a>\n";
}

You might want a more generic variable name so you can use it with the Next link, which would be the same concept.

Incrementing or decrementing $screen with $screen++/$++screen and $screen--/$--screen wouldn't work as it would cause problems with the Next link.

Borzoi 24 Posting Whiz

Your problem is with your IF statement on lines 14/15. You're checking the variable $screen before you're putting anything in to it:

if (!isset($screen))
    $screen = 0; else echo $_GET["screen"];

You neede to check it $_GET["screen"] is the one which is set:

if (!isset($_GET["screen"]))
    $screen = 0; else echo $_GET["screen"];
Borzoi 24 Posting Whiz

The function parameters are Profilepic($uid,$base_url)

You seem to be passing in different variables.

I would assume that $base_url is the scripting path for the hosted domain so for a Linux hosted site, it would most likely be something like /var/www/vhosts/example.com/htdocs but you'll need to confirm that with your host if it's not your own server. This would probably be declared either earlier in the file or in an include.

$uid is obviously the unique identifier for the user you're getting the profile picture for.

Borzoi 24 Posting Whiz

$_GET[screen] should be $_GET["screen"] and will not have a value unless the URL of the page is appended with ?screen=value where "value" is the value.

Borzoi 24 Posting Whiz

You're basically converting the array to a variable. Instead of the output being:

Array ( [0] => One [1] => Two [2] => Three [3] )

You're changing it so it becomes:

One, Two, Three, 

Like I said, it's not a clean fix and it's something I came up with in a second. I can describe what all parts of my code does in detail if you want.

Borzoi 24 Posting Whiz

This isn't a clean fix (someone may be able to provide a better one) but you could loop through the array, placing each entry of the array into an appended variable.

$newvariable = ""; //create the variable

for ($i= 0; isset($result[$i]); $i++)
{
    $newvariable .= $result.", "; //Add the current array entry to the variable, appended with a comma and space.
}

The problem with this is that there will be a trailing comma and space at the end.

Borzoi 24 Posting Whiz

Could you expand on your query? This doesn't sound like it's PHP or even web development related.

Text files are just plain text, no formatting. They cannot hold images. For an RTF, you just past the image in to the file.

Borzoi 24 Posting Whiz

Have you tried storing the results of print_r to a variable?

$newvariable = print_r($result);

I've not tried that myself but the theory here would be that the output is stored in the variable, which you can then pass to the database.

Borzoi 24 Posting Whiz

Captcha isn't going to stop the mail being marked as spam. That just reduces the chance that the form is going to be abused.

Borzoi 24 Posting Whiz

You shouldn't have a colon after the if queries and you aren't using braces. I'm also pretty certain that the value for a box to be unchecked is actually just blank, not "unchecked". I suggest trying this:

<td>FooterMenu</td>
<td><input type="checkbox" name="FooterMenu" value="1" checked="<?php if($FooterMenu == 1){echo "checked";}else{echo "";} ?>" /></td>
Borzoi 24 Posting Whiz

This isn't going to be your PHP code causing the filtering to spam. If your domain doesn't already have one, you want to set up an SPF record which states the server which this script is on is allowed to send mail. I don't know if maysite.com is one you've used just as an example but that domain doesn't have an SPF record.

You'll also want to make sure the content of the mail isn't spam-like.

Borzoi 24 Posting Whiz

A lot of web hosts will have the e-mail and websites on seperate servers. Even if that is the case, the mail logs will still be useful in determining the cause of the problem.

Borzoi 24 Posting Whiz

Is the e-mail for domain hosted on the same server which is sending you the e-mail? If it isn't, you'll probably find that you have a setting which lists that domain as a local domain, meaning any mail sent through or from your server to that domain will be delivered locally. If the mail isn't on that server, the message bounces. The mail sending script will still report success though.

I suggest you check your mail logs on your server to see if the messages are bouncing when sending to your domain in any case. This will tell you the reason why messages aren't getting through. The fact you mentioned Cron makes be presume this is hosted on Linux. If this is the case, the default mail log location is /var/log/maillog but it may be different on your server depending on your configuration.

Borzoi 24 Posting Whiz

If an input form was compromised at some point, adding a captcha and taking other precautions may not eliminate the problem. You might find that a PHP scrupt has been added somewhere on your server with a cron job or scheduled task set to run it every now and then. Assuming you have access to it, you'll want to check your crontab or scheduled tasks to make sure you don't have anything being executed which shouldn't be.

Borzoi 24 Posting Whiz

You don't seem to be using strtoupper() or strtolower() when checking the username. That would mean that the username needs to be input exactly as it was during signup. E.g.: If they sign up with the username "MyUsername" then try to log in with "myusername" it would fail because it doesn't match the database.

What I do with login scripts is allow the user to input their username in whatever case they want during sign up so their username could be "MyUsername" but then let them log in by typing it in any case. When checking it against the username held in the database, it would compare them both in lowercase.

Borzoi 24 Posting Whiz

I want to tell a joke about UDP but I don't know if you'll get it.

Slavi commented: good 1 :D +0
Borzoi 24 Posting Whiz

It looks as though the data is just being placed at the beginning of the table in MySQL5.1 instead of the end. Unless specified, MySQL will add the inputted data to the end of the table, not the beginning. I don't recall this being different in MySQL 5.1.

How are you calling the information from the database? I'm assuming you're using the same command to call from both like you have done when inserting data?

Borzoi 24 Posting Whiz

I've always made sure to use the strict standards. My site currently validates as both XHTML 1.1 and HTML 5 so switching was easy to do as it was just changing the doctype declaration. This wouldn't have worked for sites I've made previously but that's getting besides the point here.

Also, my goal wasn't to find out if I should change how I make sites. I was simply looking to find out people's reasoning for choosing one over the other.

Borzoi 24 Posting Whiz

I tend to use XHTML due to browser compatibility. In almost all cases where I've worked with XHTML, the content has displayed in every browser the same and the times it didn't was due to certain browsers coughIEcough not supporting the CSS styles I was using.

When HTML 5 was released, I tried it and liked it however not all browsers supported everything it had to offer and some didn't handle it as expected. Over time though, this has changed. I do find that now, it is a lot easier to make a site compatible with a large range of browsers in both HTML 5 and XHTML.

The reason I ask this is because recently, while working on a website using XHTML, I came across the need to use an iframe which isn't supported in XHTML but is in HTML 5 and that got me thinking as to why I haven't changed to using HTML 5 now that it's more cross-browser compatible than it was when it was released.

Borzoi 24 Posting Whiz

That return command gives me an error when I restart nginx to apply the changes:

nginx: [emerg] invalid number of arguments in "return" directive in /etc/nginx/conf.d/default.conf:19
nginx: configuration file /etc/nginx/nginx.conf test failed

Line 19 is your suggested code. I've put in within location / {} because you didn't specify where I need it.

Regarding try_files, I am using it for friendly URL's because I'm making my site dynamic by having just one page which loads content depending on the URL (E.g.: mysite.com/thispage will display the contents of mysite.com/index.php?page=thispage). The reason why I want to remove .php from the end is in case anyone accidentally (or even deliberately) puts .php at the end. My intention is to redirect [whatever].php to [whatever] before it starts trying to parse any PHP. Like the rewrite rule would do.

Currently, if you go to [something].php then the default 404 error page is coming up unless the file exists, in which case it runs that but I don't want it to do so.

Is what I'm trying even possible?

Borzoi 24 Posting Whiz

However, from what I hear about them these days they are pretty much evil incarnate.

They've just taken the Dungeon Keeper motto of "It's good to be bad" to heart.

Borzoi 24 Posting Whiz

Hi,

I'm not sure if I'm posting this in the correct place as this is related to nginx configuration and not specifically PHP scripts. If I am posting this in the wrong section, please let me know and I will post it in the correct location (unless a Mod is able to move threads?).

I'm configuring nginx on my server and I've got it mostly configured how I want. The last thing I need to do (for now) is remove ".php" from the URL if someone goes there. I have done some research on this but can only find information on making nginx search for "file.php" if the URL ends in "file" which is not what I want.

The information I can find mostly refers to the try_files directive and says to do this:

try_files $uri $uri.php;

This is not what I want though. What this does is if "mysite.com/something" doesn't exist, try loading "mysite.com/something.php" without writing .php to the URL. What I want is if someone goes to "mysite.com/somthing.php" to redirect them to "mysite.com/something" preferably with a 301 redirect. Reversing the above would not do anything because the $uri variable will contian ".php" if it's typed in to the address bar, making $uri.php become file.php.php.

This is very easy if I want to do it for specific files:

rewrite /page.php /page permanent;

The problem is that I want this to work for anything the end user may type.

I might be missing something very simple and trivial …

Borzoi 24 Posting Whiz

I don't know if your login code on that thread is complete but I cannot see a session being started in there. You will need to put the session_start(); command at the top of that page too. Anything you put into a session variable on a page where no session has been started won't be set.

Borzoi 24 Posting Whiz

The exit part needs to be in the if statement:

if(!isset($_SESSION['username']))
{
  header("location:index.php");
  exit;
}

Having it outside of the if will prevent all content below it being displayed.

Borzoi 24 Posting Whiz

The header(); function also needs to be before any output to the browser, if I'm not mistaken.

You basically just wamt to move the PHP in your code (lines 46-58 in the code you've given) to the top of the page, before the <!DOCTYPE> declaration.

I also recommend you put exit; after the header, within the same if statement because without it, the rest of the code will still run.

Borzoi 24 Posting Whiz

This can be done purely with CSS if it's just a drop-down menu. The <option> tag doesn't allow <img> tags to be nested in but you can use the CSS backround option. My below example assumes that each item has a different image and I'm using random cat images I found on Google in the example.

Put this in your CSS:

/*Required to make the drop-down menu box size stay normal and not increase*/
select
{
    height: 20px;
}

/*specify the size of the image*/
option
{
    padding-left: 50px; /*This needs to match the width of the image*/
    height: 50px; /*This needs to match the height of the image*/
}

/*Specify the image for each item and ensure it doesn't repeat*/
option.item1
{
    background:url('http://ecx.images-amazon.com/images/I/51quac7wzJL._SL75_SS50_.jpg') no-repeat;
}

option.item2
{
    background:url('https://fbcdn-profile-a.akamaihd.net/hprofile-ak-ash4/373022_109028169156820_1762275121_q.jpg') no-repeat;

}

option.item3
{
    background:url('http://static.zsl.org/images/width50/tabby-cat-cat-map-13274.png') no-repeat;

}
option.item4
{
    background:url('https://profile-b-ord.xx.fbcdn.net/hprofile-frc3/373166_211062615614589_1144510708_q.jpg') no-repeat;

}
option.item5
{
    background:url('https://profile-a-sea.xx.fbcdn.net/hprofile-prn2/186922_1140912124_762827619_q.jpg') no-repeat;

}

You then just need to add the classes to each option:

<select>
    <option class="item1">Test item 1</option>
    <option class="item2">Test item 2</option>
    <option class="item3">Test item 3</option>
    <option class="item4">Test item 4</option>
    <option class="item5">Test item 5</option>
</select>

Remember to include your name/id and other attributes alonside the class. I've never tried making it a grid view though so not sure if that would be possible but if I have time, I'm going to try.

riahc3 commented: Non dynamic -1
Borzoi 24 Posting Whiz

And there's the headdesk. That worked without problem.

Thanks for that. I can't believe I missed something so obvious.

Borzoi 24 Posting Whiz

Hi there, I've not been on here in a while. I'm having trouble with a PHP function and I'm pretty sure I'm missing something very obvious or I'm doing something wrong so hopefully someone can help me reach that inevetable facepalm or headdesk when I realise what I'm doing wrong sooner.

I've created a very basic function to simply call the various parts of the page to display.

function content ($pagecontent)
{
    $content = "";

    $content .= include("/header.php");
    $content .= $pagecontent;
    $content .= include("footer.php");

    return $content;
}

This is only partly working however. The content from the includes are being placed in the variable and returned but for some reason, when I try to pass something in to the $pagecontent variable, it seems to come empty.

The $pagecontent variable contains what it says - the page content. An example page script using the function:

<?php
    $mypage = ((results from scripts grabbing content from database and formatting etc));

    content($mypage);
?>

If I echo the $mypage variable (between the two includes like the function) directly on the page, the content is displayed however it doesn't seem to want to pass itself to the function as when I call the function, passing the variable to it, only the includes are displayed. If I am not mistaken (which I must be looking at the results), the content of the variable should be passed to the function as above.

Any help or pointers would be appreciated.

Borzoi 24 Posting Whiz

@paulkd: It was the path specified in the $new variable that was wrong. Specifically a folder name. The if statement only checked if the $old variable had a valid file so it outputted "yes" because the original file existed. After being able to view the error stating that the "file or folder does not exist" I spotted the error instantly. The code I put in my original post wasn't copy-pasted. I had written it out instead.

@igbal51: I use Notepad++ to code for syntax highlighting only. I don't use a WYSIWYG or any other code editor which adds loads of useless and non-compliant code.

Borzoi 24 Posting Whiz

I had completely forgot about the ini_set function. Just tried it and it's not disabled so that's helped a huge amount.

The problem was actually a mis-spelling in the path name. Simple error but I completely missed it, looking for a more complicated one.

Thanks for all your help.

Borzoi 24 Posting Whiz

Thanks for the suggestion but it's not in ready only.

Since posting, I tried using copy() and unlink() but they also don't affect the file. When I put a die() message then the error is displayed but without the PHP error log, I don't know why it's failing. I'm suspecting that a configuration on the server may be preventing it because the script is working on my own server without problem. The PHP versions are different but are both PHP 5.X.

I have an alternative in place at the moment but it requires more work for the user.

Borzoi 24 Posting Whiz

Hi everyone. It's been a while since I've needed help with a PHP problem. Hopefully someone here knows what I'm doing wrong because I can't see it.

I am trying to use rename() to rename an image file which is in a subdirectory of a subdirectory the script is running in. The script is running in "/folder" and the images are held in "/folder/images/general"

The script I currently have is:

$old = "./images/general/item2.jpg";
$new = "./images/general/item44.jpg";

if(file_exists($old))
{
    rename($old, $new);
    echo "yes";
}
else
{
    echo "no";
}

The if statement is finding the file as my browser is outputting "yes" however the file is not being renamed. The permissions of the image file are 644 which as far as I am aware, is all it needs to be but I have tried with the permissions set to 666 and even 777. Have I missed something increadibly obvious?

I need the script to be able to rename the image as it's uploaded (was going to have it uploaded, then renamed unless there's a more efficient way?) and to rename files which already exist.

Unfortunately, error logging is disabled on the server this is hosted on and I don't have the necessary access to enable it. Is there maybe something I can put in die() to output the PHP error to the browser just like die(mysql_error()); would output the MySQL error?

Borzoi 24 Posting Whiz

Pretending it started working randomly isn't going to help anyone. We're all human and miss things sometimes. Admitting to my mistake will hopefully help others who are having a similar problem.

diafol commented: well said +14
Borzoi 24 Posting Whiz

I found the problem. It looks like I had accidentally changed the line specify the name of the .htaccess file in the httpd.conf file. The line should read:

AccessFileName .htaccess

But I had accidentally changed it to:

AccessFileName .htacess

Which was causing the problem. I've corrected it and restarted apache and it's now working correctly.

Borzoi 24 Posting Whiz

That's what I had beforehand but that's not working. I want my site redirecting away from www and not to it so this is what I have for domain redirection:

RewriteEngine on
RewriteCond %{HTTP_HOST} !^domain\.co\.uk$
RewriteRule (.*) http://domain.co.uk/$1 [R=301,L]

I must have screwed something up in my httpd.conf file I reckon so I'm going to try rebuilding it and see if that helps.

Borzoi 24 Posting Whiz

Sorry for the late reply.

Yes, I have tried another cable. I used a cable I know definitely works as it is used in another external HDD.

I'm going to close this as there's nothing else to be added at this point. Thanks for the help everyone.

Borzoi 24 Posting Whiz

I have a server which is hosting just a single site and because of this, I intend to redirect all traffic from domains which isn't mine to my domain. For example, if a random person decides for some reason to point their domain to my server, when my server gets the request it redirects to my domain. I have tried various rules in teh .htaccess then going to the IP address to test this but each time I try, it stays on the IP address and doesn't redirect to the domain. Because of this, I decided to start working on just getting it to redirect from the IP to the domain. This is what my .htaccess file currently looks like:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^1\.2\.3\.4
RewriteRule (.*) http://domain.com/$1 [R=301,L] 

I have checked through my httpd.conf file and ensured that .htaccess is enabled and that the FollowSymLinks option is enabled (which is why it is not in the .htaccess file) but the redirect still isn't working. I've had a look online and I can't see anything wrong with what I have in my .htaccess file. Could someone give me some pointers on what I need to do or change?

You've probably already worked it out but the IP and domain in the above is not my IP or domain...

Borzoi 24 Posting Whiz

Hello everyone. Hopefully somebody can help me.

I have an old 250 GB external HDD which I used to use for data storage. It's a fairly old model (bought it in 2005) and the USB port on the caddy seems to be broken. At first, I could have the HDD connrcted if the USB cable was in a specific position but that no longer works.

I was wondering if someone could tell me if this particular external HDD is, like most, an internal drive in a shell or an actual drive.

Unfortunately, I don't have the model number but it's a Freecom 250 GB external HDD. It looks exactly like this: http://img.dooyoo.co.uk/GB_EN/orig/0/4/0/3/9/403989.jpg

If anyone does know if it is an internal drive in a shell, please let me know.

The shell on it is quite tight so I'm going to need tools to rip it off. The drive has had this problem for a couple of years now, I've just not had anything to transfer the data to until now so I haven't bothered to try.

---
Below is information that can be skipped as it's just background on what's on the drive.

I used to use the drive for storage, as if it was an internal (I know, bad idea) and because of this, it has data on it I wish to get off it that I don't have backed up anywhere. Some of it I don't mind losing but a lot of it I would …

Borzoi 24 Posting Whiz

I currently have a problem where DVD's will not output any audio to the front speakers of my 5.1 surround sound unless something else is also sending audio there. For example, I watch a scene with lots of dialogue but I only have the background audio. If I open up my audio test at during this time and click on a front speaker to test, the test audio plays and I can also hear the audio from the DVD which should be coming from the front speakers (the speech).

This problem happens in every DVD playing software used. I have gone through all the audio settings in the various programs but nothing changes. Because this happens in every DVD playing software, I figure this must be something outside of the software. I have tried updating audio codecs and also changing settings for the DVD drive (disabling digital audio) but this doesn't help.

I use VLC media player but I have also tried Windows Media Player and Easy DVD player (somthing I found on Download.com).

In VLC, I have tried every 5.1 audio setting but to no avail. If I set it to Stereo, Mono or even 2 Front 2 Back I get all audio, just not correctly.

One other thing I have noticed is that in VLC (and Easy DVD), I could only select 5.1 surround if I had "Force detection of Dolby Surround" to "Yes" or "True" in the settings which suggests that for some reason, the software cannot …

Borzoi 24 Posting Whiz

It's just a basic bash script.

The solution was a lot simpler than I was making it. Since I only actually needed the first output from the find, I just put it in to a variable which meant only the first result was written and then checked if the variable had content:

#!/bin/bash
location=(`find / -maxdepth 4 -name "filename"`)

if [ $location ]
then
     echo The file already exists at $location
else
     touch /path/to/file
     echo The file has been created.
fi

For those who are curiou, the reason I have the -maxdepth parameter is because there's only a few locations the file would be. The script isn't actually checking for a file but rather a program. If it's not installed, it installs it then runs it but if it's already installed, it'll simply run it.

Borzoi 24 Posting Whiz

I am trying to write a shell script but I only want it to run if there are no files with a specific name found on the server. I know how to check for a specif file which would be done like this:

if [ -f /path/to/file ]
then
    echo The file already exists
else
    touch /path/to/file
fi

The above requires that I know the path to the file however. The script I am creating is supposed to search the server to see if a file with that name already exists and if it doesn't, run the commands and preferably, if the file does exist, display it's location but I can't figure out how this would be done.

I can use find to specify the file like so:

find / -name "filename"

Which either comes up with results or nothing, which is expected. What I want to happen is if find has no results then I want it to run a command and if it does have results, display those results. Here's some pseudo code of what I want it to do:

if [ find / -name "filename" > 0 ]
then
    echo The file already exists at (location)
else
    create the file
fi

Hopefully that makes sense.

Borzoi 24 Posting Whiz

I'm guessing nobody knows what could be happening?

This has stumped everybody I know.

Borzoi 24 Posting Whiz

It's the Cisco VPN client 5.0.01.0600.
This is the only VPN client on the computer.
Most of my tests have me leaving the network the VPN created disabled as I know that it automatically gets enabled when the VPN connects.
The event viewer has no errors, just that the service started and stopped:

I've removed my computer name from the below snippets.

Start Event:

Event Type: Information
Event Source:   Service Control Manager
Event Category: None
Event ID:   7036
Date:       14/05/2012
Time:       20:45:40
User:       N/A
Computer:   
Description:
The Cisco Systems, Inc. VPN Service service entered the running state.

For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.

Stop event:

Event Type: Information
Event Source:   Service Control Manager
Event Category: None
Event ID:   7036
Date:       14/05/2012
Time:       20:45:40
User:       N/A
Computer:   
Description:
The Cisco Systems, Inc. VPN Service service entered the stopped state.

For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.

As you can see, the service is stopping before even a second goes by.

Borzoi 24 Posting Whiz

I have spent weeks looking for a solution online but I have turned up with nothing.

I am running Windows XP Professional (this has been tried on both service pack 2 and service pack 3) but every time I try to run the Cisco VPN client I get "Error 56: The Cisco Systems, Inc. VPN Service has not been started. Please start this service and try again"

The obvious solution: Start the service. I do this from services but the service will not stay active. I sometimes get a message saying that it started then stopped and that some services will stop when not used but other times it simply stops. Either way, it will not stay on.

Searching online, the only solution I could find was to disable the service for Internet Connection Sharing. I have disabled "Windows Firewall/Internet Connection Sharing (ICS)" in services and set the start up to Manual so that it doesn't start on boot.

Here is a list of everything I have tried and the results:

  1. Manually starting the service - Service stops instantly
  2. Disabling Internet Connection Sharing and starting the VPN service - same result as 1.
  3. Enabling the network created by the VPN software - is constantly "Obtaining IP address" and doesn't start the service. Starting the service at this point yeilds the same results as 1. and also disables the VPN network connection.
  4. To esure it was installed properly, the VPN client was uninstalled and all records of it removed from the …
Borzoi 24 Posting Whiz

2 questions:

1. What port does TeamViewer run on?
2. Is there a linux client?

Borzoi 24 Posting Whiz

I currently have a small script I've written that basically takes an incremental backup of a folder which looks similar to this:

#!/bin/bash

cp -ruf /home/folder4/subfolder/ /home/folder5/
cp -ruf /home/folder3/subfolder/ /home/folder4/
cp -ruf /home/folder2/subfolder/ /home/folder3/
cp -ruf /home/folder1/subfolder/ /home/folder2/

Now this runs fine, only updating the files that have been modified and not asking me if I want to overwrite each individual file. There's only one problem that I can't figure out a solution.

Basically, I want this to remove any files which are not present in a newer version. For example:

In /home/folder1/subfolder/ I start off with 3 files:

file1
file2
file3

I run the script and now /home/folder2/subfolder/ contains the same data as /home/folder1/subfolder/. If I then remove file2 and add file4 and file5 to /home/folder1/subfolder/ the directory listing would be:

file1
file3
file4
file5

If I run the script at this point, the new files would be copied over and if file1 and file3 were modified, they would be copied too but it will not remove file2 from /home/folder2/subfolder/ which is what I want it to do.

I know that I could set the script to remove /home/folder2/subfolder/ then copy over /home/folder1/subfolder/ but that would mean it would copy over all files and not just the updated/new ones which I don't want to do, especially when there's a lot of files to copy over.

Besides removing the whole folder and its contents, is there a way to remove the files …

Borzoi 24 Posting Whiz

I can't install software on the computer I would be l using to access my computer.

Borzoi 24 Posting Whiz

Remote desktop is my only option.