freebsd

How can I get the behavior of GNU's readlink -f on a Mac?

ε祈祈猫儿з 提交于 2019-12-27 10:28:42
问题 On Linux, the readlink utility accepts an option -f that follows additional links. This doesn't seem to work on Mac and possibly BSD based systems. What would the equivalent be? Here's some debug information: $ which readlink; readlink -f /usr/bin/readlink readlink: illegal option -f usage: readlink [-n] [file ...] 回答1: readlink -f does two things: It iterates along a sequence of symlinks until it finds an actual file. It returns that file's canonicalized name—i.e., its absolute pathname. If

Can someone explain the source of the `cd` shell command?

ぐ巨炮叔叔 提交于 2019-12-25 08:26:21
问题 $ cat $(which cd) #!/bin/sh # $FreeBSD: src/usr.bin/alias/generic.sh,v 1.2 2005/10/24 22:32:19 cperciva Exp $ # This file is in the public domain. builtin `echo ${0##*/} | tr \[:upper:] \[:lower:]` ${1+"$@"} My interest lies in understanding who records the state change after calling cd. Is it in a file? 回答1: This is not the cd builtin, and it doesn't actually work, except to tell if a directory can be changed into, by failing with a nonzero exit status if it cannot. Try it: "$(which cd)" / .

Incorporating I/O driven scheduling into OS Kernel

这一生的挚爱 提交于 2019-12-25 07:06:01
问题 IronPort developed a high performance file system and an I/O driven scheduler optimized for the asynchronous nature of messaging (hence "Async"OS). If you wanted to do the same but make it open source, what exactly would need to change? 回答1: This is probably mostly marketing - FreeBSD already handles "asynchronous nature of messaging" rather well. They most likely short-circuited some processing in the network stack for their specific purposes, same for the file system. 来源: https:/

Bash script to display Mac Airport MAC address

此生再无相见时 提交于 2019-12-25 02:09:47
问题 I'm not good at scripting but found this site so hopefully some kind people out there can help me :) I need a bash script to display the Airport Mac Address of machines, I think the command is.. ifconfig en1 ..which brings up the correct result in Terminal but I dont know how to utilise this. I'm using Casper Suite in an office environment and need to get a report that display the MAC address of the wireless (airport) ports. To show you how Casper works here's a script that someone wrote to

Concatenating text and command output in Bash script to output to file

只谈情不闲聊 提交于 2019-12-25 01:22:18
问题 I'm writing a bash script in FreeBSD that appends commands to a log file. Before I execute the commands that will append the log data, I want to print a line in the file which shows the current date above the data, like this: ---Tue Aug 20 17:26:37 EDT 2019--- I know that I can use the date command to output the timestamp, but I'm not sure how to include the "---" before and after the timestamp to add to the file. What's the simplest way to do this? 回答1: You can pass a format string to date:

c++ code doesn't catch exception on FreeBSD

不打扰是莪最后的温柔 提交于 2019-12-24 15:12:54
问题 I have a program running on many different linux distros. When I compile it on FreeBSD 10.1 for some reason the catch clauses stop working and exceptions that should get caught crash my program. When debugging I modified one of the catch clauses to "catch (...)" and still the exception wasn't caught. I guess the issue is related to the linker, but I don't know how to debug it futher. When I tried compiling a test program that simply throws and catches and exception it worked - so I guess the

getdate.y grammar doubts

落爺英雄遲暮 提交于 2019-12-24 11:37:00
问题 http://www.freebsd.org/cgi/cvsweb.cgi/~checkout~/src/usr.bin/tar/Attic/getdate.y?rev=1.9.12.1;content-type=text%2Fplain;hideattic=0 I am trying to understand how yyTimezone is calculated in code below: | bare_time '+' tUNUMBER { /* "7:14+0700" */ yyDSTmode = DSToff; yyTimezone = - ($3 % 100 + ($3 / 100) * 60); } | bare_time '-' tUNUMBER { /* "19:14:12-0530" */ yyDSTmode = DSToff; yyTimezone = + ($3 % 100 + ($3 / 100) * 60); } How I understand is, lets say the timestamp is 2011-01-02T10:15:20

dlerror: Undefined symbol “_nss_cache_cycle_prevention_function” on FreeBSD 7.2

爱⌒轻易说出口 提交于 2019-12-24 09:52:57
问题 I have an ANSI C program that dynamically loads a .so file using dlopen() passing RTLD_LAZY. I receive Undefined symbol "_nss_cache_cycle_prevention_function" warnings whenever the .so file is accessed in FreeBSD 7.2. nss_cache_cycle_prevention_function() is not one of my program's functions and I imagine must be coming from FreeBSD. This might also be a problem on Linux too although I am not experiencing the issue there. I would prefer not to load FreeBSD specific header files into my

passing struct pointer to functions not working

醉酒当歌 提交于 2019-12-24 07:15:11
问题 Motive: Passing struct to functions such as we can change it in any function and retrieve any value in any function. I picked up this code from: http://cboard.cprogramming.com/c-programming/126381-passing-structure-reference-through-4-functions.html#post942397 I tweaked it a little and here it is: struct_passing.h typedef struct thing { char *x; }thing_t; struct_passing.c #include <stdio.h> #include "struct_passing.h" void f4(thing_t *bob) { bob->x = "changed"; } void f3(thing_t *bob) { f4

How to configure bash to print utf8 error message?

試著忘記壹切 提交于 2019-12-24 06:39:19
问题 Strange UTF-8 handling in bash. $ á bash: $'\303\241': command not found when run tcsh, so $ tcsh #or exec tcsh > á á: Command not found. What can be wrong? How to setup bash for utf8 correctly? And before mark this question as duplicate, please, read the next too: My .inputrc : set meta-flag on set input-meta on set output-meta on set convert-meta off set show-all-if-ambiguous On "\e[A": history-search-backward "\e[B": history-search-forward set -o vi my ENV: LOCALE=UTF-8; export LOCALE