w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Referential integrity checking in table definition
Have you tried using the SQL CHECK constraint? http://www.w3schools.com/sql/sql_check.asp You're going to need a composite foreign key to provide the check you want.

Categories : SQL

Auto run script in root mode
You should use sudo - your command available in root mode without password for user or group Cmnd_Alias YCMD = /usr/local/somecommand username ALL=YCMD, NOPASSWD: YCMD

Categories : Unix

Running shell script as root using apache/php
You look for tool called sudo: https://en.wikipedia.org/wiki/Sudo But most likely instead of going for sudo you should rethink your app architecture as once your httpd is compromised, attacker can easily get root rights.

Categories : PHP

How to check if running as root in a bash script
If the script really requires root access then its file permissions should reflect that. Having a root script executable by non-root users would be a red flag. I encourage you not to control access with an if check. chown root:root script.sh chmod u=rwx,go=r script.sh

Categories : Bash

Checking progress of a PHP script with AJAX
By default, your session variables are not updated until the script terminates. You'll have to call session_write_close() in order to persist the data.

Categories : PHP

How to run a Ruby script in Sublime Text 2 from project root
Depending on your scripts you might want to look into using Package Control and the SublimeREPL Package. SublimeREPL allows you to have a Ruby Interpreter in a separate tab or window in SublimeText. Running CMD + Shift + B has never been very reliable in SublimeText for Ruby code anyways. Also, similar answer to similar question: Execute Ruby code in sublime text 2

Categories : Ruby

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

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

How to execute local script as root in remote servers?
Use SSH Keys to avoid having to enter a password view this link: https://wiki.archlinux.org/index.php/SSH_Keys

Categories : Linux

How to run tshark commands from root mode in linux using TCL script ?
You have to either elevate the privileges of your tshark process via sudo (or any other available means) or run your whole script with elevated privileges. One way to do that which might be simpler than sudo as it would require zero customizations is to write a super-simple C program which would just run /usr/bin/tshark with the necessary arguments and then make that program setuid root and distribute along with your Tcl program. That is only needed if you need portability. Otherwise sudo is much simpler.

Categories : Linux

checking number of arguments bash script
Just like any other simple command, [ ... ] or test requires spaces between its arguments. if [ "$#" -ne 1 ]; then echo "Illegal number of parameters" fi Or if test "$#" -ne 1; then echo "Illegal number of parameters" fi When in Bash, prefer using [[ ]] instead as it doesn't do word splitting and pathname expansion to its variables that quoting may not be necessary unless it's part of an expression. [[ $# -ne 1 ]] It also has some other features like unquoted condition grouping, pattern matching (extended pattern matching with extglob) and regex matching. The following example checks if arguments are valid. It allows a single argument or two. [[ ($# -eq 1 || ($# -eq 2 && $2 == <glob pattern>)) && $1 =~ <regex pattern> ]] For pure arithmetic

Categories : Bash

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 to reset the Registry Editor view back to root using VB script?
By deleting the "LastKey" which holds the last key viewed in the Registry Editor, the view returns to the root view. WshShell.RegDelete "HKLMSOFTWAREMicrosoftWindowsCurrentVersionAppletsRegeditLastKey"

Categories : Windows

When checking every checkbox with script, Knockout model does not get updated
In KnockoutJS, the observable array just keeps track of the amount of items in the array and reports changes (i.e. adding/removing items), but it does not keep track of the state of the objects within that array. It sounds like you want to have an observable array of observables. Do you have a model object that represents each checkbox in the list? Here is a fiddle that shows the tracking of checkboxes within an observable array.

Categories : Javascript

How do i write a shell script for checking website live or not
Change it do this: if [ $(curl -s --head --request GET http://opx.opera.com/opx/version | grep "200 OK" > /dev/null) ] && [ $(curl -s --head --request GET http://oss.opera.com/version | grep "200 OK" > /dev/null) ] To check the status of a command inside an if, you have to do it like if [ $(command) ] while you were using if [ command] note also the need of spaces around [ ]: if [_space_ command _space_ ] Update Based on Ansgar Wiechers's comment, you can also use the following: if curl -s --head --request GET http://opx.com/opx/version | grep "200 OK" > /dev/null && curl -s --head --request GET http://oss.com/version | grep "200 OK" > /dev/null; That is, if command && command

Categories : Bash

jQuery script for checking if input has any value. Issue in IE and Chrome
There is a typo in your code ' is missing after selector Use $('.comment_input') instead of $('.comment_input) In line $('.comment_input).keyup(function(){ Edit: use .prop() instead of .attr() Working code JS: $('.comment_button').prop('disabled', true); $('.comment_input').keyup(function () { $('.comment_button ').prop('disabled', $.trim($(this).val()).length == 0); }); HTML: <input type="text" class="comment_input" name="somethng"/> <button class="comment_button">something</button> Fiddle Demo

Categories : Javascript

Batch script checking file size methods?
The only thing I can think of is the file must not exist, in which case %%~zi expands to nothing (not 0). That is easily fixed by explicitly setting size to 0 afterward if size is not defined. for /f %%i in ("file.txt") do set "size=%%~zi" if not defined size set size=0 if %size% gtr 0 ( type file.txt >> %FNAME% ) else ( echo No Data Found On System >> %FNAME% )

Categories : Batch File

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

Jquery script for checking if input is not empty. A space button issue
trim the value using trim() and then check for the length if you don't want to send just the spaces. $(document).ready(function () { $('.post_button').attr('disabled', true); $('.message').keyup(function () { if ($.trim($(this).val()).length != 0) { $('.post_button').attr('disabled', false); } else { $('.post_button').attr('disabled', true); } }) }); Use $.trim($(this).val()) as $(this).val().trim() doesn't work in IE8.

Categories : Javascript

Checking cmd line argument in bash script bypass the source statement
Try storing the values of your positional paramaters first on an array variable then reset them to 0. "$XILINX/../settings32.sh" may be acting differently when it detects some arguments. # Store arguments. ARGS=("$@") # Reset to 0 arguments. set -- # load Xilinx environment settings source "$XILINX/../settings32.sh" cp -r "../../../EDK/platform" "hw_platform" if [[ ${#ARGS[@]} -ne 0 ]]; then cp "${ARGS[0]}/system.xml" hw_platform/system.xml fi echo "Done"

Categories : Linux

executing a perl script on a remote machine as a root and getting the output back into the webpage using javascript
To initiate a command from a web page, issue an AJAX call to another CGI script running on your webserver. AJAX call can return the results of running your command (typically in JSON or XML format) and then call up some JavaScript handler to render that data in your page's DOM. To run something as root on the web server's unix machine locally, you will need an suid script to be called from your CGI script mentioned in the first bullet (since web server and all the scripts it runs are typically run as non-root for security reasons). To run something as root on ANOTHER machine, you have correctly found that you need to use ssh (from that same CGI script): ssh root@your_remotehost "perl pathto/perlfile.pl" You will need to set up the ssh keys correctly between 2 systems so ssh doesn't ask

Categories : Javascript

PHP: fopen path for `include`d script using Apache Document Root when full path is specified?
If the Path starts with / It will point to the root Filesystem which is fine with CLI but CGI would understand it this way: /home/jweinberger/com.example/logs/script1.log//home/jweinberger/logs/script1.log You should use the index 'DOCUMENT_ROOT' from the $_SERVER array. fopen($_SERVER['DOCUMENT_ROOT'].'/home/jweinberger/logs/script1.log')

Categories : PHP

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

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

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

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

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

API Integrity issue?
Subtasks are first-class tasks and can belong to projects in their own right. So, for example, if task A has subtask B, and subtask B is in project P, then when you fetch tasks for project P, you will get B in the results. Does this map to what you're seeing, or is the subtask not explicitly in the project you requested?

Categories : Api

sqlalchemy integrity error
Indeed your method is prone to integrity errors. What happens is that when you invoke Foo.get(1,2,3) 2 times, you do not flush the session in between. The second time you invoke it, the ORM query fails again - because there is no actual row in the DB yet - and a new object is created, with different identity. Then on commit/flush these 2 clash causing the integrity error. This can be avoided by flushing the DB after each object creation. Now, things work differently in SQLAlchemy if the primary key is known in merge/ORM get - if the matching primary key is found already loaded in the session, SQLAlchemy realizes that these 2 must be the same object. However no such checks are done on unique indexes. It might be possible to do that also. However it would make race conditions only rarer, as

Categories : Python

Referential integrity for mysql
You only have to index the fields used in the foreign key relationships, and recent version of mysql do this automatically for you anyways. It's not "overkill". it's actually an optimization. Consider that anytime you update/delete/insert a record, the foreign tables have to be checked for matching records - without the indexes, those checks could be glacially slow.

Categories : PHP

Referential integrity access
Your intersection table should not include the Program/Partner Names at all, it should only include the Program/Partner ID values. By keeping a copy of the names in the intersection table you have denormalized your data. This is generally considered to be a "Bad Thing".

Categories : Database

Use Cityhash for file integrity
This is not an appropriate application for CityHash, and it will exhibit poor collision resistance when used this way. If you want a quick file integrity checksum, use a CRC family function, like CRC16. If you want something more extensive, the speed of cryptographic hashes such as SHA1 should be more than sufficient. (Almost any modern CPU can hash data basically as fast as it can read it from memory.)

Categories : C++

PDO Integrity constraint violation
Seeing how there's an error even though you have a ON DUPLICATE KEY construct, it would be likely the problem is in the UPDATE portion. I noticed that you're reusing :nid twice; you will want to use a different alias for the second occurrence, i.e.: INSERT INTO totalresponses (nid, created) VALUES(:nid, :created) ON DUPLICATE KEY UPDATE nid = :nid2, created = :created '); Then bind :nid2 to $item['nid']. From the PDO::prepare() manual entry: You cannot use a named parameter marker of the same name twice in a prepared statement.

Categories : PHP

How to implement referential integrity here?
I think you can just use foreign keys as you would expect: CREATE TABLE [dbo].[Documents]( [DocID] [int] IDENTITY(1,1) NOT NULL, [NoDoc] [char](9) NULL, [IdClient] [varchar](10) NULL, [AdrNum] [tinyint] NULL, [DateDoc] [smalldatetime] NOT NULL, CONSTRAINT [PK_DocID] PRIMARY KEY (DocId), CONSTRAINT FK_DOC_Clients FOREIGN KEY (IdClient) references Clients (IdClient), CONSTRAINT FK_Doc_Addresses FOREIGN KEY (IdClient,AdrNum) references DeliveryAddresses (IdClient,AdrNum) ) If one or more column values in the referencing side of a foreign key is NULL, then the foreign key constraint is not checked. Conversely, there's no way to have NULL be a foreign key reference.

Categories : Sql Server

How to add integrity constraint check on all controllers in YII?
CMysqlSchema is the class for retrieving metadata information from a MySQL database and COciSchema is the class for retrieving metadata information from an Oracle database.u can make use of the methods provided by these classes to check for the constraints for example u can make use of the method findConstraints()

Categories : Misc

How to ensure the integrity of application data?
I know that Android supports MODE_PRIVATE flag when creating a file so that no other application can access it This is the default behavior for internal storage. however is there a way to like add a digital signature or something that the application can check on startup? You are welcome to create a digital signature for a file. Anyone who modifies the file is welcome to modify the digital signature. will that prevent the user from accessing/deleting the file(s) from file manager or any other app? Ordinary users will not be able to access files on internal storage. Users who root their device are able to access internal storage if they choose to. If not, could you suggest a method to add a digital signature to the file(s) in the onDestroy() method of the MainActivity a

Categories : Java

file upload integrity check
Finding the size is not a completely reliable solution. I would recommend you to use checksum for checking the integrity of file transferred. Client should calculate the checksum of file it is sending, send the checksum value with the request as a param. On the server side, again checksum should be calculated and compared against the checksum sent by the client. If two matches, file is good! Here is a sample to generate checksum in java: http://www.mkyong.com/java/how-to-generate-a-file-checksum-value-in-java/

Categories : Java

Integrity Error - Flask & SQLAlchemy
Okay, the reason for this is a bit tricky :) The error message does indeed mean that this email address is already in the DB. But why the heck is this? Because the debug flag tells the built-in server to also use the reloader. And this reloader basically makes the app run twice on the first start. You can see that in the output: $ python2 server.py worked * Running on http://127.0.0.1:5000/ * Restarting with reloader Not Working There are multiple ways to get around that. Quick'n'dirty would be to just disable the reloader: app.run(debug=True, use_reloader=False) A better way would be to not populate the test DB that way. Instead I suggest using Flask-Script.

Categories : SQL

What transactions diminish data integrity?
This is a good question. Shows that you've been thinking about it a bit. The problem you are describing exists because the database is not aware of your data dependencies. To the database, your code selects some data and writes some data. It doesn't know you are only writing that data based on the data selected. In general, you need to tell the database about your data dependencies. This is done differently in each database. You mentioned MySQL. InnoDB has support for SELECT ... FOR UPDATE. This will issue a lock for the resource so that other queries cannot access the resource (depending on transaction isolation level). This will make the second transaction in your example not be able to execute until the first one commits, if they are locking the same resources. Which resources it lo

Categories : SQL



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