w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Batch Script to Delete Files with Unique Root Stem in Directory
The way i'd go about this is as follows, i will explain the logic and i'll leave you to do the coding. You will parse all the file names into variables, while increasing each time. Then you will set a limit to the number of loops to go through. Then you will search the first 13 characters of the file name and if the number of lines is equal to 1 then delete it. After you will increase the variable by 1 and go through the loop, at the end of each loop it will check if it has reached the limit aka the number of files in the directory, if it has reached the limit, end the loop, otherwise continue. hah, i finally decided to do it after a guy decided to use my idea i described into actual code, anyway this is way shorter and a lot faster than his, tested+verified to work: @echo off & setl

Categories : Batch File

Linux skip /root/.gvfs when executing df command with non-root user
I got the solution for my own question :) In df command you can pass the file system types which you would like to exclude, in this case it is 'fuse.gvfs-fuse-daemon'. So when I execute the below the command I no more get this message "df: `/root/.gvfs': Permission denied" df -x fuse.gvfs-fuse-daemon For more details one can look into df --help option.

Categories : Linux

Is sudo-ing tomcat's startup with a non-root user the same as running it as root?
Do be aware that the recommended solution to run tomcat on port 80 is to use mod-jk with the Apache web server, not to have tomcat listen on port 80 directly.

Categories : Unix

phonegap set the root directory for asset files
Maybe a solution is to use the base tag witch allow you to set a default base to all yours relatives links. So for android it will be: <base href="file:///android_asset/www/" target="_blank"> And all yours link will be: <img src="img/logo.png">

Categories : Cordova

Get user root directory from windows service
I found this under Win7 registry. XP looks to have the same registry keys, but the values have "All Users" profile within it. [HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionExplorerShell Folders] "Common Desktop"="C:\Users\Public\Desktop" "Common Start Menu"="C:\ProgramData\Microsoft\Windows\Start Menu" "CommonVideo"="C:\Users\Public\Videos" "CommonPictures"="C:\Users\Public\Pictures" "Common Programs"="C:\ProgramData\Microsoft\Windows\Start Menu\Programs" "CommonMusic"="C:\Users\Public\Music" "Common Administrative Tools"="C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Administrative Tools" "Common Startup"="C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup" "Common Documents"="C:\Users\Public\Documents" "OEM Links"="C:\ProgramData\OEM Links" "Common Template

Categories : C#

How to get relative path of files from defined root directory?
That would be os.path.relpath(): >>> import os >>> filename = "C:/test/media/blog_images/2013/06/15/yay.gif" >>> blog_images = "C:/test/media/blog_images/" >>> os.path.relpath(filename, blog_images) '2013\06\15\yay.gif'

Categories : Python

How to make apache2 user to access the file in /root directory?
First, it is generally a bad idea to give apache access to root. If you insist ... Install ACL (Access Control List) Installing ACL Then, assuming your apache server runs with 'apache2' for it's user and group, give the apache2 user and group access to directories/files: setfacl -m "group:apache2:r-x" /root/whatever.file setfacl -m "user:apache2:r-x" /root/whatever.file # *** only need the next two lines if you plan on writing new files in the specified directory. It sets the default file permissions that will be used when the new file is created. setfacl -d -m "group:apache2:r-x" /root setfacl -d -m "user:apache2:r-x" /root Change the r-x permissions to whatever you need Edit - potential solution without ACL The following is untested and may require tweaking but should get you

Categories : PHP

Jetty bash script works only with root user
Check the ${jetty.home}/logs/start.log (or similarly named log file) That will tell you why it failed. Also, you might want to look into the optional setuid support. http://www.eclipse.org/jetty/documentation/current/setuid.html

Categories : Linux

Running python cron script as non-root user
Cron jobs run with the permissions of the user that the cron job was setup under. I.E. Whatever is in the cron table of the reports user, will be run as the reports user. If you're having to so sudo to get the script to run when logged in as reports, then the script likely won't run as a cron job either. Can you run this script when logged in as reports without sudo? If not, then the cron job can't either. Make sense? Check your logs - are you getting permissions errors? There are a myriad of reasons why your script would need certain privs, but an easy way to fix this is to set the cron job up under root instead of reports. The longer way is to see what exactly is requiring elevated permissions and fix that. Is it file permissions? A protected command? Maybe adding reports to certai

Categories : Python

Windows batch script to name files after containing subfolder and copy to root
Here I made this my self. I created a similar situation to yours and it worked fine for me. However you have to specify the location to copy all the files to. for /d %%a in (*) do ( cd %%a for /r %%b in (*) do ( copy %%b C: [root] \%%a%%~xb ) cd.. ) pause Hopes this helps. Yours Mona.

Categories : Windows

How do I create a batch script that creates a task for a specific user in the Active Directory?
For it to run as that user you need to specify both username and password. schtasks.exe /create /? [snip] /U username Specifies the user context under which the command should execute. /P password Specifies the password for the given user context. [snip] So, for user 'jsmith', with password 'password1', your command will end up looking something like: schtasks.exe /create /u jsmith /p password1 /sc once /tn defrag /tr "\compnameC$Windowssystem32defrag.exe c:" /st 14:33:00

Categories : Windows

git pull executed as wrong user. Unable to edit files now
# chown -R your_user git_repo_directory This will set you (username youruser) as the owner of the git_repo_directory. -R tells to apply the new owner to files recursively.

Categories : GIT

wrong child root name in rabl and can't set child root name
I've encountered the same exact bug, the problem seems to be setting the object_root to false. Following the comment of Bigxiang I have experimented a bit and found that this works fantastically: child( {:rsvp => :rsvp}, {:object_root => false} ) do extends "users/index" end Note both the round parentheses "()" and braces "{}".

Categories : Ruby On Rails

For a Ruby CLI, what is the most reliable way to change directory to users root/home directory?
To summarize Avdi Grimm's screencast on the same subject, If you're using a Ruby version greater than 1.9, the Dir module provides a method #home. However, this depends on the environment variable HOME set on the user's shell session. To reliably get the home dir, you should pass in the login name of the current user to the Dir.home command. Or, in code: # Works if HOME is set in the environment i.e., if "echo $HOME" returns the home directory # when that command is run on the command-line Dir.home # => /Users/<username>, Works if HOME is set # If the HOME environment variable is not set, you should explicitly pass in the username # of the currently logged-in user Dir.home(username) # => /Users/<username> # The current username can be obtained using username

Categories : Ruby

How to set up local repo to have different root directory than remote "upstream" directory of an open source project?
Broadly speaking, No. Git does not allow you to have two different view of the same repository that have different directory structures. Solution 1: Ignore git altogether for uploading That said, I think you don't need this anyway. If your webhost provides public_html, why not just scp the files you want to the location you want? You could make this a task in a Makefile/Rakefile/whatever and then run it from your local machine when you want to upload, for example, a makefile task could look like: upload: scp -r ./upload/* me@myhost:/home/me/public_html/ .PHONY: upload Solution 2: link into your git directory on your webhost Instead of manually uploading your files, simply link your public_html directory to your upload directory in your git repository on your server. For example:

Categories : GIT

Root immediate child nodes icons not visible when hiding root
JTree#setShowsRootHandles(boolean newValue) controls the state of the handles for root elements. Normally, this is false. Try changing to true

Categories : Java

Read and Write root folder wihout root
You can use run-as on some devices to execute commands as a particular package. Google have fixed this on Jelly Bean so it no longer works: adb shell run-as app.package.name cp /data/data/package.name/file.txt /sdcard/ exit adb pull /sdcard/file.txt ~/ Here is a good article explaining file access in Android without root permissions, including a one-liner for the above script. It details how to use the new backup command: backup -f ~/data.ab -noapk app.package.name And how to extract the contents of the resulting .ab file: dd if=data.ab bs=1 skip=24 | openssl zlib -d | tar -xvf - You will most likely need the android.permission.BACKUP permission.

Categories : Android

Reset MAMP Pro username and password to root/root
Assuming you still know the password, you can change the password back to root using /Applications/MAMP/Library/bin/mysqladmin -u root -p password root It'll prompt you to enter a password again, after which it'll be reset to root

Categories : Mysql

upload image to root directory from sub directory php
As far as I know there is no problem with accessing other directories, as long as your user has sufficient file access permissions. Maybe try using a full file path $_SERVER["SCRIPT_FILENAME"] and save your file with an absolute path?

Categories : PHP

How to get the root directory
Use Path.GetPathRoot method provided by the framework Gets the root directory information of the specified path For your case you can use: string rootPath = Path.GetPathRoot(filename);

Categories : C#

zip with php in root directory
Use the second parameter of ZipArchive::addFile() to specify under which file name the file appears in the archive. basename($file) is a good candidate for that.

Categories : PHP

SVN (svnserve) virtual root --root= not recognized
svn+ssh handles the whole transaction including writing and reading the files so it ignores the --root parameter in svnserve. Here is how to fix it over at serverfault -- Basically you just make svnserve into a script that calls svnserve with the proper variables.

Categories : Svn

Download to root directory
Try something like this: Dim baseDir As String = AppDomain.CurrentDomain.BaseDirectory Dim launcherDir As String = Path.Combine(baseDir, "Launcher") If Not Directory.Exists(launcherDir) Then Directory.CreateDirectory(launcherDir) End If Dim targetFile = Path.Combine(launcherDir, Path.GetFileName(fileUrl)) Me.downloader.DownloadFileAsync(New Uri(fileUrl), targetFile, Stopwatch.StartNew)

Categories : Vb.Net

PHP warning from root directory
Either: Include relative the the file: __DIR__.'/../somefile';/__DIR__.'/somepath/somefile'; Include relative to a known dir: $_SERVER['DOCUMENT_ROOT'] is often used, as is a PROJECT_DIR-like define() in your bootstrap code. Change the working directory to a known/static dir chdir('/some/dir');. Not recommended as calling code may not expect this.

Categories : PHP

.net chooses the wrong root folder
In your web.config, set: <authentication mode="Forms"> <forms ... defaultUrl="~/" ... /> </authentication> Reminder: / - Site root ~/ - Root directory of the application The difference is that if you site is: http://example.com And you have an application myapp on: http://example.com/mydir/myapp / will return the root of the site (http://example.com), ~/ will return the root of the application (http://example.com/mydir/).

Categories : Asp Net

Split-Path with Root UNC Directory
By using the System.Uri class and querying its host property: $uri = new-object System.Uri("\serverfolder") $uri.host # add "\" in front to get exactly what you asked Note: For a UNC path, the root directory is the servername plus the share name part.

Categories : String

How do I get the root directory of my ASP.NET server application?
Server.MapPath("~"); Will get you the root directory of the current application, as a path on the disk. E.g., C:inetpub... Note that the ~ character can be used as part of web paths in ASP.NET controls as well, it'll fill in the URL to your application.

Categories : Asp Net

Travis CI with Rails Not In Root Directory
I'll try and address what you should change one error at a time. With the first error: The command "psql -c 'create database test-postgres_production;' -U test-postgres" failed and exited with 2 during before_script. Let's add the following to get a postgres database going on Travis CI: env: - DB=postgresql script: - bundle exec rake db:migrate - bundle exec rake db:test:prepare - bundle exec rake spec before_script: - bundle exec rake db:create RAILS_ENV=test Now that we're running a rake tast to create the database you should be able to remove what you currently had in before_script: Now for the second error: -mongodb: unrecognized service I think you just need a space before the mongodb like so: services: - mongodb And with the third and last error: rake abor

Categories : Ruby On Rails

Getting Revisions ONLY in my directory and not in root Repository
I figured out my issue this morning, to answer my own question, when working with subfolders out of a checked out repository, every time a svn update -r PREV command is called, it updates to the previous revisions in me directory. However, running svnversion on at that point will give you the previous revision in ../../repos/users to solve this issue, I called svn info . in the me directory and noted that the Last Changed Rev: had the number that I needed. To get this I called svn info (this is in php btw): exec('svn info .', $info); Then I used a regular expression to grab the key: $versionKey = array_keys(preg_grep('/Last Changed Rev/', $info)); And then set the version to that revision number using substr with an offset of 18: $version = substr($info[$versionKey[0]], 18);

Categories : PHP

what would be the path for the file in the root directory?
When you say "root directory" that usually means the root directory of a filesystem. On most *nix (Linux, FreeBSD, Unix) installs, that means your filesystem path is simply "/". That is, if your config file is there, your PHP file should look like this: <?php include('/config.php'); ?> However, it would generally be both a bad idea and would require superuser privileges to actually put a file at the filesystem root of "/". So it's likely (but we have to guess), that you mean the DOCUMENT ROOT for your web server. Most web servers running PHP make that value available via the super-global $_SERVER['DOCUMENT_ROOT'] as mentioned by Kai Qing in his comment. If that is where your file is, then you could put this in your PHP file: <?php include($_SERVER['DOCUMENT_ROOT']

Categories : PHP

IIS MVC wrong root path points to localhost
You should be using a relative path from the application root, using this: <a class="logo" href="@Url.Content("~/")">Application</a> Note the ~ (tilde) before the forward slash. Also, an option would be to use the Url to an action: <a class="logo" href="@Url.Action("Index","Home")">Application</a>

Categories : Asp Net

Phonegap Build - Get application root directory?
In my case after asking the guys at phonegap, they say that you dont really need to do any of this can just use location.hostname so am looking at using that approach for now, the main reason for asking this is because in trigger.io I would be using tools.getUrl. So I assumed in Phonegap I would need to do something similar. http://legacy-docs.trigger.io/en/v1.4/modules/tools.html

Categories : Javascript

Find the root directory without full path in C#
If the subfolder is under the same root as you application you can use Directory.GetDirectoryRoot See: http://msdn.microsoft.com/en-us/library/system.io.directory.getdirectoryroot.aspx

Categories : C#

Upload file into Server Root directory
Use Apache's FTP library to browse and retrieve files from your servers filesystem. You can list out all the files in the root directory by using: .listFiles() Example: String hostname = properties.getProperty("FTP_SERVER"); String user = properties.getProperty("FTP_USER"); String passwd = properties.getProperty("FTP_PASSWD"); FTPClient client = new FTPClient(); client.connect(hostname); client.login(user, passwd); String reply = client.getStatus(); System.out.println(reply); client.enterRemotePassiveMode(); client.changeWorkingDirectory("/"); FTPFile[] files = client.listFiles();

Categories : Java

How to run the powershell code against each subfolder that is in the IIS root directory?
You need to separate folder-traversal (recursive) from file processing (non-recursive), e.g. like this: $basedir = 'c:inetpubwwwroot' $exp = [regex]::Escape($basedir) $server = 'http://172.16.x.x' function Create-HtmlList($fldr) { Get-ChildItem $fldr -Force | ? { -not $_.PSIsContainer } | select ... ... } | Set-Content "$fldr.htm" } # list files in $basedir: Create-HtmlList $basedir # list files in all subfolders of $basedir: Get-ChildItem $basedir -Recurse -Force | ? { $_.PSIsContainer } | % { Create-HtmlList $_.FullName } The output files will be put into the respective folder (named after the folder with the extension .htm appended). If you want a different name or location for the output files, you need to adjust the Set-Content line in the function

Categories : Powershell

PHP root folder directory - include_once and echo
First you need to declare your root variable like so: $baseURL = "../.."; // or whatever it is Then you can use the variable in the include like so: include_once("{$baseURL}/asset/header.php"); // means include_once("../../asset/header.php"); Just make sure when you put the path inside of include_once, you use DOUBLE quotes and not single quotes, or else you can't incorporate variables like above. Edit: One thing to remember, $baseURL must be in the scope of your include. As in, if it's a global and you're using it inside of a function, make sure you declare it as a global. More on scopes: http://php.net/manual/en/language.variables.scope.php

Categories : PHP

IIS 7 virtual directory not targeting website root?
To troubleshot 500 errors on IIS, you need to get the substatus (for example 500.19), then check the error code, in the case of 500.19 errors (the more common), you can start here: http://blogs.iis.net/webtopics/archive/2010/03/08/troubleshooting-http-500-19-errors-in-iis-7.aspx. If you're not getting the substatus and/or error code, then you should access the site in the server using localhost.

Categories : HTML

PHP script dynamic display of files in directory based on user privileges?
You will need stored into $_SESSION the value of the fields LTP and MSV and try somethig like this in the php file that your are using to read those folder read LTP folder if(!empty($_SESSION[LTP])){ //code to read LTP folder }else{ //Cannot read LTP folder } read MSV folder if(!empty($_SESSION[MSV])){ //code to read MSV folder }else{ //Cannot read MSV folder } Assuming 0 is deny acces and 1 is grant permission to read

Categories : PHP

How to ignore subfolders and redirect to the root directory with .htaccess
Remove the second RewriteCond which checks if directory doesn't exist !-d <IfModule mod_rewrite.c> RewriteEngine On RewriteBase /demo/ RewriteRule ^index.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteRule . /demo/index.php [L] </IfModule>

Categories : Htaccess

effects of initializing git repository on linux root directory 3:)
Instead of using git you could use a filesystem that support snapshots, like ZFS or BTRFS it will be more efficient and it's usage will be transparent to you.

Categories : GIT



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.