username

access Bash environment variable in Python using subprocess

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-11 14:44:11
问题 I can determine the width of the terminal in Python with a subprocess-handled query such as the following: int(subprocess.Popen(['tput', 'cols'], stdout = subprocess.PIPE).communicate()[0].strip('\n')) How could I determine the Bash user name in a similar way? So, how could I see the value of ${USER} in Python using subprocess? 回答1: As Wooble and dano say, don't use subprocess for this. Use os.getenv("USER") or os.environ["USER"] . If you really want to use subprocess then Popen(['bash', '-c'

Case-insensitive user-names in Symfony2

半世苍凉 提交于 2019-12-11 13:59:49
问题 By default, Symfony2 matches usernames case-sensitively. I want users to be able to enter johnsmith , JohnSmith , johnSMITH , or any variant of that, and have them all register as johnsmith . How do I do this? I though the easiest way would be to always convert each username to lower-case before comparing them. This is easy to do on the one side (just throw a lower() into the SQL statement), but how do I do that for what the user types in in the login form? Since Symfony automatically takes

UIWebView passing username and password into a form

无人久伴 提交于 2019-12-11 13:52:14
问题 I have a UIWebView set up containing my universitys intranet page, my code will pass in my username fine (as it is a number) NSString *studentNumber = @"639909"; NSString *javaScriptNumber = @"document.getElementById('username').value=%@;"; javaScriptNumber = [NSString stringWithFormat: javaScriptNumber, studentNumber]; [webViewInt stringByEvaluatingJavaScriptFromString: javaScriptNumber]; However when i try to run the same code to fill in the password field, it will only work with numbers,

How do I start an SSH session locally using Python?

让人想犯罪 __ 提交于 2019-12-11 12:41:18
问题 What I mean to ask is, if I am on System "A" (Linux) and I want to ssh into System "B" (Windows): On System "A", I can do ssh admin@xx.xx.xx.xx which will prompt me to a password and when that gets authenticated, I will get to the "$" of System "B" (on System "A"). how do I send username and password together as a single line (since I want to use a script) How to achieve the scenario that I have above. 回答1: I generally do it with Paramiko, its easier import paramiko # ssh print 'enter ssh'

Username mod rewrite

走远了吗. 提交于 2019-12-11 11:06:13
问题 I need help with mod rewrite ...I'm trying to change domain.com/user.php?username=foo to domain.com/foo My current rewrite is: RewriteRule username/(.*)/ user.php?username=$1 [L] RewriteRule username/(.*) user.php?username=$1 [L] which outputs domain.com/username/foo but i'm not happy with that. 回答1: You want: RewriteRule ^(.*)/ user.php?username=$1 [L] RewriteRule ^(.*) user.php?username=$1 [L] This will send every request to user.php. If you don't want that it's probably better to send

How to obtain username/name for a company facebook account?

你说的曾经没有我的故事 提交于 2019-12-11 10:31:40
问题 Right now I am using the graph API explorer and I have a company type Facebook account. However, the following command do not return "username"/"name" field. I did set a proper username in the Profile page -> Basic Information -> Name/Username (both) http://graph.facebook.com/11234545656556 (the number is fake for now) This is the response that I received: {"id": "11234545656556", "link": "http://www.facebook.com/profile.php?id=11234545656556", "timezone": 0, "locale": "en_US", "verified":

Applying .htaccess folder username/password with PHP

时间秒杀一切 提交于 2019-12-11 07:22:41
问题 I’m building a PHP/MySQL web application. Users log in and various session variables are set. There’s a folder on the webserver where users can upload files to (any kind – images, pdf, .doc etc). I’d like to protect this folder to prevent people who are not logged in typing in the url and getting to these files. Browsing of files in this folder is disallowed. I can apply a password using my cpanel, which works nicely. However it means that users have to log in to the application, then the

JQuery Username Validation

拜拜、爱过 提交于 2019-12-11 04:07:36
问题 Does anyone have a working example of a username checker using jquery validation and jquery addmethod? Something like this: $("#register_form").validate({ onkeyup:false, rules: { username: { required: true, minlength: 3, usernameCheck: true // remote check for duplicate username }, }); jQuery.validator.addMethod("usernameCheck", function(username) { var isSuccess = false; $.ajax({ url: "username_availability.php", data: "username=" + username, async: false, type: "POST", success: function(msg

Open Directory directory domain name on Mac OS X

北城以北 提交于 2019-12-11 03:34:55
问题 I can retrieve the logged in user name using NSUserName(), but how do I get the Open Directory "directory domain name" or other domain he is a member of? i.e. similar to the notion in Windows where a logged-in user is DOMAIN\USERNAME, where DOMAIN is his local machine, workgroup or Active Directory domain. 回答1: You may be able to do this with Directory Services. Alternatively, check out the new Open Directory APIs introduced in 10.6; you have a choice between a Core-Foundation-based API and a

How to make url /username in codeigniter?

大兔子大兔子 提交于 2019-12-10 10:29:29
问题 I'm using codeigniter at the moment. I am currently able to view a persons profile by the using /user/profile/profile_id but I want to make it so that a user can just navigate to a profile using /username to make it simpler. How would I go about doing this I'm not sure where to start? class User extends CI_Controller{ public function index(){ if($this->session->userdata('is_logged_in')){ redirect('user/profile'); } } public function profile(){ $profile_id = $this->uri->segment(3); $ip = $this