Wednesday, March 30, 2011

CACLS command for windows changing mode permission


It is a command line utility which displays and modify Access Control Lists (ACLs) in windows environment(Microsoft windows NT) of files and folders. An Access Control List is a list of permissions for securable object, such as a file or folder, that controls who can access it.
 
XCACLS.exe : It's a updated version for cacls for windows 2000 and later.
 
CACLS filename [/T] [/E] [/C] [/G user:perm] [/P user:perm [...]] [/D user [...]]
 
Options:
filename: Name of the file to be modify ( * wildcard for all files )
/T            Changes ACLs of specified files in the current directory and all subdirectories.
/E            Edit ACL instead of replacing it.
/C            Continue on access denied errors.
/G user:perm  Grant specified user access rights.
/P user:perm  Replace specified user's access rights.
/D user       Deny specified user access.--
 
Perm can be:
N  None
R  Read
W  Write
C  Change (write)
F  Full control
 
Examples:
1: to replace ACL with Full access permission to current directory and all subdirectories for user "test"
>cacls * /T /P test:F
2. To edit ACL for particular user "test" with Change access for abc.text file without changing other permission.
> cacls abc.text /E test:C
 
Also look for chmod a linux command for changing file permissions.
 

Tuesday, March 8, 2011

Sending AT commands using microsoft hyperTerminal

MS Hyperterminal is a small program which can be used for sending AT commands to ur GSM/3G phone connected as modem to ur PC. For linux users minicom can be used as HyperTerminal.
for getting hyper terminal in windows Vista and 7 use this link
Hyperterminal can be found in start->programs->accessories->communications->Hyperterminal

You should first check ur device whether it's connected properly, and working fine or not.

Now you should set up ur device as modem. In Hyper terminal you can start a new connection and select the com port where your device is appearing (check in device manager).

Now you can send the AT commands to ur device.

Now you should Type "AT" in the main window.
A response "OK" should be returned from the modem.
Now type "AT+CPIN?" in the main window.
The AT command "AT+CPIN?" is used to query whether the modem is waiting for a PIN ( i.e. password). If the response is "+CPIN: READY", it means the SIM card doesn't require a PIN and its ready for use.
else you can set the PIN using "AT+CPIN=<pin>"



Alternatives for Hyper Terminal in windows vista and Windows7

for getting hyper terminal in windows Vista and 7 use this link or you can use following options:

> windows remote shell (WinRS)
> use phone and modem options if you are using Hyperterminal for modem connections (AT Command).
> Can use Putty also. Download putty.exe

For getting more info on WinRS type "winrs /?" in your command prompt.

Wednesday, November 17, 2010

Conversion of macros into String literals

The # preprocessor operator converts the argument that follows it into a string literal. The preprocessor operator # can be used only in a function-like macro definition.

#include <stdio.h>

#define PRINT(name) printf("The value of " #name " is %d\n", name)

main()
{
 int abc = 100;

 PRINT(abc);
}
Output: The value of abc is 100
Macro Expansion
--> printf("The value of " #name " is %d\n", name)
--> printf("The value of " "abc" " is %d\n", 100)
--> printf("The value of abc is %d\n", 100)
The unary # operator produces a string from its operand. Adjacent string literals are getting concatenated in above example. If the operand to # contains double quotes or escape sequences, they are also expanded.
Similarly ## operator concatenate two tokens passed in macro to a single token.

#define JOIN(a,b)  a ## b
main()
{
   int myname = 100;
   printf("%d", JOIN(my,name));
}
It will be converted into printf("%d", myname);