PC를 새로 받아서 vagrant 설치하고 기존 환경 로드하는 과정에서 아래와 같은 에러를 내음



Failed to mount folders in Linux guest. This is usually because
the "vboxsf" file system is not available. Please verify that
the guest additions are properly installed in the guest and
can work properly. The command attempted was:

mount -t vboxsf -o uid=`id -u vagrant`,gid=`getent group vagrant | cut -d: -f3` /vagrant /vagrant
mount -t vboxsf -o uid=`id -u vagrant`,gid=`id -g vagrant` /vagrant /vagrant



이런 경우 아래와 같이 vagrant-vbguest 플러그인을 설치하면 해결됨.



설치후 VM 다시 로드




아마도 VBox 버전 업하면서 vagrant 플러그인들 compatibility에서 이슈가 발생하지 않았을까 추정함.


다시 로드하면서 에러 발생할경우에는 vagrant ssh로 VM 접속후 apt-get update; apt-get upgrade 로 패키지들 업데이트 진행 한 뒤에 다시 reload 수행.


저작자 표시
신고
Creative Commons License
Posted by rookiejava

[출처 : http://www.perlmonks.org/ ]

Answer: How to run a shell script from a Perl program?
contributed by radiantmatrix

Perl offers three slightly different mechanisms for executing external commands:

  1. system
  2. exec
  3. Backticks or qx//
  1. Using system

    system($command, @arguments); # For example: system( "sh", "script.sh", "--help" ); system("sh script.sh --help");
    System will execute the $command with @arguments and return to your script when finished. You may check $! for certain errors passed to the OS by the external application.

    Read the documentation for system for the nuances of how various invocations are slightly different.

  2. Using exec

    This is very similar to the use of system, but it will terminate your script upon execution. Again, read the documentation for exec for more.

  3. Using backticks or qx//

    my $output = `script.sh --option`; my $output = qx/script.sh --option/;
    The backtick operator and it's equivalent qx// excute the command and options inside the operator and return that commands output to STDOUT when it finishes.

There are also ways to run external applications through creative use of open, but this is advanced use; read the documentation for more.

Answer: How to run a shell script from a Perl program?
contributed by snapdragon

The way to do this is to use a systen call to run your script:

system("script.sh");

However I thought that I'd mention a couple of points to go with this. 

  1. Don't assume that your shell environment variables will be kept - a shell script that works fine on the command line may not work when run from Perl
  2. Be careful with your directories - try to make sure you're executing from the right place. It's often worthwhile to do a chdir to the right directory in Perl before calling your script. i.e.  chdir "/path/to/script/";

Good luck!
Answer: How to run a shell script from a Perl program?
contributed by Plankton

I like to do this sometimes ...

my $shell_out = <<`SHELL`; for fs in `/sbin/fdisk -l | grep -v swap | grep Linux | cut -d ' ' -f1 +` do /sbin/e2label \$fs | grep recovery > /dev/null 2>&1 && echo "Y +ES" && exit 0 done echo "NO" exit 0 SHELL
... to capture the stdout of the shell commands in a scalar var.
Answer: How to run a shell script from a Perl program?
contributed by ruzam

A slightly longer version using the exec method with forked pipes (and an optional timeout value).

# two parameters: # cmd - a command or reference to an array of command + arguments # timeout - number of seconds to wait (0 = forever) # returns: # cmd exit status (-1 if timed out) # cmd results (STDERR and STDOUT merged into an array ref) sub ExecCmd { my $cmd = shift || return(0, []); my $timeout = shift || 0; # opening a pipe creates a forked process my $pid = open(my $pipe, '-|'); return(-1, "Can't fork: $!") unless defined $pid; if ($pid) { # this code is running in the parent process my @result = (); if ($timeout) { my $failed = 1; eval { # set a signal to die if the timeout is reached local $SIG{ALRM} = sub { die "alarm\n" }; alarm $timeout; @result = <$pipe>; alarm 0; $failed = 0; }; return(-1, ['command timeout', @result]) if $failed; } else { @result = <$pipe>; } close($pipe); # return exit status, command output return ($? >> 8), \@result; } # this code is running in the forked child process { # skip warnings in this block no warnings; # redirect STDERR to STDOUT open(STDERR, '>&STDOUT'); # exec transfers control of the process # to the command ref($cmd) eq 'ARRAY' ? exec(@$cmd) : exec($cmd); } # this code will not execute unless exec fails! print "Can't exec @$cmd: $!"; exit 1; }
Answer: How to run a shell script from a Perl program?
contributed by DeadPoet

If you want the PID, STDOUT, and STDERR, use IPC::Open3.

Example:

use IPC::Open3; local (*IN, *OUT, *ERR); my $pid = eval{ open3( \*IN, \*OUT, \*ERR, 'my_command', 'my_command_args' ); }; if ($@) { warn ($@); } ## capture your output, if needed... ## wait on the pid... wait( $pid, 0 );
저작자 표시
신고
Creative Commons License
Posted by rookiejava

아웅... 한두번 하는것도 아닌데...
할때마다 헷갈려서 검색하는것도 귀찮아서 그냥 글로 남겨둬야겠다..


[출처 : http://linuxproblem.org ]

SSH login without password

Your aim

You want to use Linux and OpenSSH to automize your tasks. Therefore you need an automatic login from host A / user a to Host B / user b. You don't want to enter any passwords, because you want to call ssh from a within a shell script.

How to do it

First log in on A as user a and generate a pair of authentication keys. Do not enter a passphrase:

a@A:~> ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/a/.ssh/id_rsa): 
Created directory '/home/a/.ssh'.
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/a/.ssh/id_rsa.
Your public key has been saved in /home/a/.ssh/id_rsa.pub.
The key fingerprint is:
3e:4f:05:79:3a:9f:96:7c:3b:ad:e9:58:37:bc:37:e4 a@A

Now use ssh to create a directory ~/.ssh as user b on B. (The directory may already exist, which is fine):

a@A:~> ssh b@B mkdir -p .ssh
b@B's password: 

Finally append a's new public key to b@B:.ssh/authorized_keys and enter b's password one last time:

a@A:~> cat .ssh/id_rsa.pub | ssh b@B 'cat >> .ssh/authorized_keys'
b@B's password: 

From now on you can log into B as b from A as a without password:

a@A:~> ssh b@B hostname
B

A note from one of our readers: Depending on your version of SSH you might also have to do the following changes:

  • Put the public key in .ssh/authorized_keys2
  • Change the permissions of .ssh to 700
  • Change the permissions of .ssh/authorized_keys2 to 640




저작자 표시
신고
Creative Commons License
Posted by rookiejava

SQL As Understood By SQLite

SQLite understands most of the standard SQL language. But it does omit some features while at the same time adding a few features of its own. This document attempts to describe precisely what parts of the SQL language SQLite does and does not support. A list of SQL keywords is also provided. The SQL language syntax is described by syntax diagrams.

The following syntax documentation topics are available:

The routines sqlite3_prepare_v2(), sqlite3_prepare(), sqlite3_prepare16(), sqlite3_prepare16_v2(), sqlite3_exec(), and sqlite3_get_table() accept an SQL statement list (sql-stmt-list) which is a semicolon-separated list of statements.

sql-stmt-list:

syntax diagram sql-stmt-list

Each SQL statement in the statement list is an instance of the following:

sql-stmt:

syntax diagram sql-stmt



[출처 : http://www.sqlite.org/lang.html]

신고
Creative Commons License

'TIP & TALK > Linux' 카테고리의 다른 글

How to run a shell script from a Perl program?  (0) 2011.02.18
SSH login without password  (0) 2011.01.20
SQLite Query Syntax  (1) 2010.10.23
missing sentinel in function call  (1) 2010.10.18
Ubuntu NTFS HDD or Partitionnig Problem  (0) 2010.07.16
Ubuntu 파티션 관리  (0) 2010.07.16
Posted by rookiejava

GCC 4 warnings about sentinels

Null-terminate parameter list

Some functions have a variable number of arguments, where the argument list has to be terminated with a NULL value. To solve this warning, null-terminate the list of parameters.

Introduction

When compiling something with GCC 4, it may be possible that you get one of the following warnings:

warning: missing sentinel in function call 
warning: not enough variable arguments to fit a sentinel

This document explains what these warnings mean and how to resolve them.

Sentinels & warnings

A sentinel is a special value which indicates the end of a series of data. In the context of GCC, it is a null pointer which ends a list of parameters to a function.

The function

execl(const char * path, const char * arg, ...)

takes a variable amount of parameters. To know where to stop reading parameters, the last parameter must be a null pointer. When you do not end the list with a null pointer,execl will not stop scanning, which will result in errors. The following code, therefore, is wrong:
#include <unistd.h>

int main() {
	execl("/bin/ls", "ls", "-l");
	return 0;
}

The execl function call is not terminated by a null pointer and GCC will give a warning. The following code is better:

#include <unistd.h>

int main() {
	execl("/bin/ls", "ls", "-l", NULL);
	return 0;
}

As you can see, the execl function is now terminated by a null pointer and it will stop scanning it's arguments after that. However, GCC 4 will still issue a warning: 
warning: missing sentinel in function call 
This is because NULL is not of the right type: it is defined as integer 0 instead of a pointer with the value 0. Doing an explicit cast can make the warning go away:

#include <unistd.h>

int main() {
	execl("/bin/ls", "ls", "-l", (char *)NULL);
	return 0;
}

Using sentinels

One can specify that a function uses a sentinel by declaring it as follows:

char * build_path(const char * str, ...) __attribute__((__sentinel__(0)));

This indicates that the parameter list is ended with the special value 0, which must be a char pointer.

On most systems, there is no difference between 0 and (char *)0. On 64 bit systems, however, the integer 0 is 32 bits and the pointer 0 is 64 bits. The compiler does not know whether it is an integer or a pointer, and defaults for the integer. This will not clear the upper 32 bits and the function will not stop scanning its parameters.


출처 : http://www.linuxonly.nl/docs/2/2_GCC_4_warnings_about_sentinels.html
신고
Creative Commons License

'TIP & TALK > Linux' 카테고리의 다른 글

SSH login without password  (0) 2011.01.20
SQLite Query Syntax  (1) 2010.10.23
missing sentinel in function call  (1) 2010.10.18
Ubuntu NTFS HDD or Partitionnig Problem  (0) 2010.07.16
Ubuntu 파티션 관리  (0) 2010.07.16
Unix socket 사용시 주의사항  (0) 2010.05.04
Posted by rookiejava
1. Go to Applicatoin -> Add/Remove
2. Modify "Show" mode as All avaulable appications
3. search "NTFS"
4. Install "NTFS COnfiguration Tool"
5. Go to System -> Administaration -> NTFS Configuration Tool
6. Enable your internal/external device to support write
신고
Creative Commons License

'TIP & TALK > Linux' 카테고리의 다른 글

SQLite Query Syntax  (1) 2010.10.23
missing sentinel in function call  (1) 2010.10.18
Ubuntu NTFS HDD or Partitionnig Problem  (0) 2010.07.16
Ubuntu 파티션 관리  (0) 2010.07.16
Unix socket 사용시 주의사항  (0) 2010.05.04
Manual Reference Pages - SIGNAL  (0) 2010.04.30
Posted by rookiejava

* 디스크 및 파티션 정보 확인http://rookiejava.tistory.com/owner/entry/edit/60#void

# sudo fdisk -l

* 디스크 UUID 확인

# ls -lh /dev/disk/by-uuid

* 파티션 할당

# sudo fdisk /dev/sdb1

* 파티션 포맷

# sudo mkfs.ext3 /dev/sdb1

* 자동 마운트 설정 (fstab 편집)

# sudo vim /etc/fstab
UUID=XXXXXXXXXXX /backup ext3 defaults,errors=remount-rw 0 1

* mount 정보 갱신

# sudo mount -a


* 파티션 편집기 GUI 설치
# sudo apt-get install gparted
참고 : http://ubuntu.liberotown.com/52


신고
Creative Commons License

'TIP & TALK > Linux' 카테고리의 다른 글

missing sentinel in function call  (1) 2010.10.18
Ubuntu NTFS HDD or Partitionnig Problem  (0) 2010.07.16
Ubuntu 파티션 관리  (0) 2010.07.16
Unix socket 사용시 주의사항  (0) 2010.05.04
Manual Reference Pages - SIGNAL  (0) 2010.04.30
DD (Data Dump) Manual  (0) 2010.04.30
Posted by rookiejava
abstract namespace에 connect할때 sun_path의 첫 바이트를 null로 시작해야 되는것을 주의하자
If sun_path starts with a null byte ('' '), then it refers to the abstract namespace maintained by the Unix protocol module http://linux.die.net/man/7/unix
신고
Creative Commons License

'TIP & TALK > Linux' 카테고리의 다른 글

Ubuntu NTFS HDD or Partitionnig Problem  (0) 2010.07.16
Ubuntu 파티션 관리  (0) 2010.07.16
Unix socket 사용시 주의사항  (0) 2010.05.04
Manual Reference Pages - SIGNAL  (0) 2010.04.30
DD (Data Dump) Manual  (0) 2010.04.30
Linux File System Cache (pdflush)  (0) 2010.04.30
Posted by rookiejava
TAG SOCKET
http://www.squarebox.co.uk/cgi-squarebox/manServer/signal.7
신고
Creative Commons License

'TIP & TALK > Linux' 카테고리의 다른 글

Ubuntu 파티션 관리  (0) 2010.07.16
Unix socket 사용시 주의사항  (0) 2010.05.04
Manual Reference Pages - SIGNAL  (0) 2010.04.30
DD (Data Dump) Manual  (0) 2010.04.30
Linux File System Cache (pdflush)  (0) 2010.04.30
VI 명령어 모음  (0) 2008.06.18
Posted by rookiejava
TAG Linux, signal
http://linux.die.net/man/1/dd

http://www.linuxcertif.com/man/1/dd/ko/


* Example
 : ./path/to/src 에서 1024 byte씩 1000번을 읽어서(block) /path/to/dest에 기록
    (일반적으로 빈 파일 만들때 보통 src를 /dev/zero로 사용한다..)
#dd if=/path/to/src of=/path/to/dest bs=1024 count=1000
신고
Creative Commons License

'TIP & TALK > Linux' 카테고리의 다른 글

Unix socket 사용시 주의사항  (0) 2010.05.04
Manual Reference Pages - SIGNAL  (0) 2010.04.30
DD (Data Dump) Manual  (0) 2010.04.30
Linux File System Cache (pdflush)  (0) 2010.04.30
VI 명령어 모음  (0) 2008.06.18
Shell script ref.  (0) 2007.11.22
Posted by rookiejava
TAG dd, Linux


티스토리 툴바