Unix How do I create a link to open an ssh connection

I am trying to create a link to open an ssh connection to another computer. I am an OS X 10.5.7 and Ubuntu 9.04 user. I am tempted to create a symbolic link as such: ln -s "ssh user@computer_name" computer_name I know this is wrong. Could someone point me in the right direction?

Unix write a background process to check process is still active

In UNIX, I have a utility, say 'Test_Ex', a binary file. How can I write a job or a shell script(as a cron job) running always in the background which keeps checking if 'Test_Ex' is still running every 5 seconds(and probably hide this job). If it is running, do nothing. If not, delete a directory at the specified path.

Unix Any method for going through large log files?

// Java programmers, when I mean method, I mean a 'way to do things'... Hello All, I'm writing a log miner script to monitor various log files at my company, It's written in Perl though I have access to Python and if I REALLY need to, C (though my company doesn't like binary files). It needs to be able to go through the last 24 hours, take the log code and check it if we should ignore or email the appropriate people (me). The script would run as a cron job on Solaris servers. Now here is what

Unix date uses gettimeofday?

When I do: date system call on freeBSD, does it internally use gettimeofday ? Another que: how do I know where the code of "date" command sitting on the system? Thanks.

Printing ASCII value of BB (HEX) in Unix

When I am trying to paste the character » (right double angle quotes) in Unix from my Notepad, it's converting to /273. The corresponding Hex value is BB and the Decimal value is 187. My actual requirement is to have this character as the file delimiter when I export a .dat file from a database table. So, this character was put in as the delimiter after each column name. But, while copy-pasting, it's getting converted to /273. Any idea about how to fix this? I am on Solaris (SunOS 5.10). Than

Unix List only certain files in a directory matching the word BOZO and ending with either '123' or '456'

I'm trying to figure out how to get a list of file names for a file named BOZO but ending with ONLY 123 OR 456. Files are: BOZO12389, BOZOand3 BOZOand456 BOZOand5 BOZOhello123 So the command should only display 'BOZOhello123' and 'BOZOand456' I can't figure it out. I've tried all forms of LS and GREP that I can think of. The funny thing is, we tried to do it in class for about 10mins and no one could get it (including the instructor).

Unix Networking Programming - Client and Server. List Function That wait for input after 40 lines

I am currently in the process of making a Client and Server in the Unix/Windows environment but right now I am just working on the Unix side of it. One of the function we have to create for the program is similar to the list function in Unix which shows all files within a dir but we also have to show more information about the file such as its owner and creation date. Right now I am able to get all this information and print it to the client however we have to also add that once the program has

Unix Recursively scp except current directory

Is there a way to scp all files in a directory recursively to a remote machine and keep their original filenames but don't copy the directory it is in? dir1/file dir1/dir2/file2 so the contents of dir1 would be copied only. dir1 would not be created. The dir2 directory would be created with file2 inside though. I have tried scp -r dir1 remote:/newfolder but it creates dir1 in the /newfolder directory on remote. I don't want it to create that dir1 directory. Just put all the files inside of

Unix How to Automate an email I

I receive an email from a user with a Excel File Monday-Friday. I usually download the file and do a name change and save it as a CSV file and load it into the server. Can I automate this process by any chance using Unix? Thank you.

Unix ftp mget not working when used in a script

I am trying to get a number of files from a Unix machine using an MS DOS ftp script (Windows 7). I am new to this so I have been trying to modify an on-line example. The code is as follows: @echo off SETLOCAL REM ################################## REM Change these parameters set FTP_HOST=host set FTP_USER=user set FTP_REMOTE_DIR=/users/myAcc/logFiles set FTP_REMOTE_FILE=*.log set FTP_LOCAL_DIR=C:\Temp set FTP_TRANSFER_MODE=ascii REM ################################## set FTP_PASSWD=password s

unix copy hidden and nonhidden one copy command

I understand how to copy a hidden folder: cp ./[^.]stringmatch /destination and I understand how to copy a nonhidden folder cp *stringmatch /desination But how do I copy both hidden and nonhidden files with a particular stringmatch?

Unix Copy files in folders by groups

I'm new to coding in Unix. I have a list of files: output_00.txt output_01.txt output_02.txt output_03.txt output_04.txt output_05.txt output_06.txt ............. output_94.txt and a list of 10 folders: output1 output2 output3 output4 output5 output6 output7 output8 output9 output10 I would like to copy the files .txt in the fold

Unix AWK print specific line based on search pattern

I have two sets of files test.csv data.xml. I am trying to grep a specific field from test.csv and search the string in data.xml. If string is found then print the corresponding line in test.csv file. Example search string is field 3 server name test.csv 111,xxx,serversugar,port90 222,yyy,servertorque,port190 333,aaa,serverastrix,port8080 422,yxy,servertorque,port290 data.xml <group> <hostname>servertorque</hostname> <hostname>serverastrix</hostname></gr

Unix checking the nth field on the n'th line within a range and other awk questions

I have a file that has a reapeating pattern like this for about 30000 lines total: K 102940 -1.34869738 20.57483945 -50.68597047 23.77974649 -24.07345423 15.78597590 --- K 102942 -1.34869738 20.57483945 -50.68597047 23.77974649 -24.07345423 15.78597590 --- I need to check the third field on the second line, if it falls within the range -20 and +20, then I'd like to print only the line that follows (the third line in above example). If the value is not in the range

Unix Different results from awk and nawk

I just ran these two commands on a file having around 250 million records. awk '{if(substr($0,472,1)=="9") print $0}' < file1.txt >> file2.txt and nawk '{if(substr($0,472,1)=="9") print $0}' < file1.txt >> file2.txt The record length is 482. The first command gave the correct number of records in file2.txt i.e.; 60 million but the nawk command gives only 4.2 million. I am confused and would like to know if someone has come across issue like this. How exactly this simple

Unix Getting the caller name of a script

I have a unix script. It has been called by some other script without proper arguments. Is there a way I can find out the caller name? grep didn't help as the name of the script is passed across several scripts and called dynamically. I want to get the script that ultimately calls my script? Anyway?

Unix What does closing a descriptor mean?

I thought a descriptor was simply a numerical index in the global file table, so I'm confused by what "close a descriptor" actually means. Can someone clarify the relationship between processes, descriptors, and open files and explain what it means to open, duplicate, and close descriptors?

Unix Slow execution of sas program in sasgrid platform

I use Unix sas in executing the sas code using sasplex platform.there is always a need to upload huge records into netezza database.i use the following script to connect/upload data into to netezza- Connect to netezza (user=s password=m server=192.168.54.32 database=test connection=global) It takes hardly 5mins to upload 5gb data in sasplex platform(sasplex) But, recently moved from sasplex to sasgrid plateform with same netezza string.but now execution time of sas program is very low.it tak

create file unix using Loop

I have a list of 87 text files populated daily in UNIX. Eg: FP*.txt --- file names start with FP & are txt files Daily new content gets appended to the end. I want to take a back up of all the text files using shell script and create blank files of the same name. I tried the following. echo "" > FP*.txt and > FP*.txt Both gave the same error. FP*.txt: ambiguous redirect however when used on single file both work fine. So how to resolve it. And also creating a list of hard-coded

Unix printer output to a file

I am using this code in Putty on Win7 to print my file on Linux. lp -d myPrinter myfile.out There is no problem with this code, it works perfectly. But I am having some Turkish character problem. So everytimeIi change something, I run this code to see if it changes. So it make wasting of paper.Now, this is my question; Is there a way to print a file on a virtual printer and to see result in a file, like microsoft XPS document writer and *.xps file. If there is, where will be the result file.

Unix SSH without password between servers using public keys

I have generated a ssh-keygen from server1, transferred it to server2 (both Ubuntu servers) using scp, added it to the .ssh/authorized_keys and then changed the permissions to both directory and file. The problem is that when i try to ssh or scp from server1 to server2, it keeps asking me for the passphrase. It worked perfectly from my mac to the server. I followed this Git keeps asking me for my ssh key passphrase which worked but after i logout from both servers, it keeps on asking me for th

Unix Makefile With an IF Statement

I have a Makefile which creates build a programme called monitor: fo/monitor: fo/monitor.c fo/inotify.c (cd fo ; $(MAKE) monitor) I have two types of system that I can run my Make on, and only wish to have have one installer. So I would like to add an IF statement to this to check for a file, and if it exists, then to build the monitor. fo/monitor: if [ -f path/to/file/exists ]; \ then \ fo/monitor.c fo/inotify.c \ (cd fo ; $(MAKE) monitor) \ else \

Not able to run the selenium webdriver suite on the Unix env

I have been trying to run the selenium tests (which is already running well on windows) using Unix, however with no luck. Could anyone please help me with how to configure the suite to make it run on the Unix..? Also if running on the Unix, how do we see the results, since to my understanding browser may be hidden during the runtime. Any help is much appreciated. Thanks

remote-access from Unix operator

Other posts have talked about using /etc/ssh/sshd_config to change the authorization settings. What Authorization settings should I set my sshd_config be on if I want this password to connect? jacobs-mbp:~ nuevo$ ssh username@141.158.1.6 The authenticity of host '141.158.1.6 (142.158.1.6)' can't be established. RSA key fingerprint is b1:0b:cn:o7:6b:f1:22:c5:x5:d1:f8:d2:63:d8:b2:2l. Are you sure you want to continue connecting (yes/no)? yes Warning

Unix Replace string in every line with a search result using Vi/Vim

I have a file that shows the output of ls e.g. /home/john/A_2014.jpg /home/john/B_2014.jpg /home/john/C_2014.jpg /home/john/D_2014.jpg now I want to use this output to write an insert script for mysql. I achieved to enter at the beginning and the end of every line the necessary code so the file actually looks like: INSERT INTO myimages (name,picture) values ('#name',LOAD_FILE('/home/john/A_2014.jpg')); INSERT INTO myimages (name,picture) values ('#name',LOAD_FILE('/home/john/B_2014.jpg'));

Unix Save each line as a separate file

I would like to save each line of my file as separate file, using column 1 as the name of the file AT1G01010 chr1 3631 5899 AT1G01020 chr1 6790 8737 AT1G01030 chr1 11649 13714 Desired output is a separate file for AT1G01010.txt whose contents are AT1G01010 chr1 3631 5899 I know in vim this is possible using the command :g/^/execute '.w '.line('.').'.txt' But this generates a file that are named after the line number, which is not exactly

Unix AWK print command for specific rows

I have millions of records in my file, what i need to do is print columns 1396 to 1400 for specific number of rows, and if i can get this in excel or notepad. Tried with this command awk {print $1396,$1397,$1398,$1399,$1400}' file_name But this is running for each row.

Unix wkhtmltopdf - How to use spaces in arguments?

I'm using wkhtmltopdf with local files. I've noticed that it doens't work with space in input/output filenames. wkhtmltopdf --footer-left reports --footer-right [page]/[toPage] -O landscape report.html report.pdf Here is a sample which gets "report.html" file, and converts to a PDF called "report.pdf", enabling a footer with a label written "reports" with the number of current and total pages. Works fine. But now I need to set a string with spaces in the footer label. I've tried different

Unix Informatica Powercenter 9.6.1 pmcmd Fatal Error

I am trying to run workflow using pmcmd in ksh and I am getting below error. ld.so.1: pmcmd: fatal: libpmasrt.so: open failed: No such file or directory startwf.ksh[18]: 7489 Killed PATH and LD_LIBRARY_PATH environment paths are already set. Any help please.

Search for lines matching pattern in specific column in UNIX

I am using HDFS to get data that meets a pattern in a specific column and want it to output the entire line. (Expecting ~2 million of 7 million lines to output) Here is my exact situation: I would like the entire line in a file where the data in the 4th column starts with a "5" For example my data set: HK|20151010|65|5005 KR|20151009|38|5092 MD|20150925|98|1943 BG|20150826|82|4892 HK|20151017|14|5002 I want the command to yield the following results: HK|20151010|65|5005 KR|20151009|38|509

Unix How to execute an SQL script for Derby DB from a ksh script

I am trying to write a small program that utilizes a sql script I wrote, to access data within a Derby DB (let's call it "myscript.sql") from within a ksh script. I seem to be running into problems however since my ksh script can only launch the "ij" tool, and is not able to input any further commands in the ij shell once opened (thus, can not connect to the DB). Is there any way that the ksh script can echo commands to the ij shell, so I can connect/execute my query as needed ?

Unix find ~/Desktop creek.jpg returns no such file or directory when creek.jpg is on my desktop. Why?

I am learning the linux utility find and am finding the man page difficult to read. I have defaulted to testing the command and seeing what it does. I have a file called creek.jpg on my desktop. When I type find ~/Desktop creek.jpg It appears to print out every file in my desktop, then prints out find: creek.jpg: No such file or directory Here is my mental picture of how find is working. In the man page, it says finds job is to "walk a file hierarchy." Here is my mental image of ho

Unix How long does compiling minix take?

I downloaded the Minix source code through git: git clone git://git.minix3.org/minix minixsrc Then I followed the instructions on Crosscompiling MINIX with build.sh and ran the command sh build.sh -mi386 -O ../build tools Now I have been waiting for about an hour for it to compile and it is continuously showing messages on my terminal like this: # compile libclangSema/SemaExprMember.lo c++ -O -O2 -fno-rtti -fno-exceptions -I. -I/home/keeyan/git/minixsrc/tools/llvm-lib/libclangSema/

Unix - Remove Leading/Trailing Spaces (Column Wise)

I have text lines like these below: P, 123456 ,01,A,H, 123456 ,123456 123456 ,, P,123456 ,01,A,H, 123456, 123456 123456,, P, 123456,01,A,H,123456 ,123456 123456 ,, P, 123456,01,A,H, 123456, 123456 123456,, P,123456 ,01,A,H,123456 ,123456 123456 ,, I want them to be like below: P,123456,01,A,H,123456,123456 123456,, P,123456,01,A,H,123456,123456 123456,, P,123456,01,A,H,123456,123456 123456,, P,123456,01,A,H,123456,123456 123456,, P,123456,01,A,H,123456,123456 123456,, Require

Unix KSH measure elapsed time

I am trying to find the day difference from the last time a password was rest to the current. So i have this so far. I am trying to just convert that date to days so i can subtract the current date in days - the last reset date in days and get a integer value. $ LASTRESETDATE=$(echo $(passwd -s) | cut -d' ' -f3) $ echo $LASTRESETDATE 12/15/16 Looking the the date verion i have there is no option for -d $ date -h date: illegal option -- h Usage: date [-u] [+format] date [-u] [mmddhhmm

What does @ mean next to the file attributes in unix?

I noticed I have one file that looks like this when I type ls -lah in the terminal: -rw-r--r--@ 1 bj5 1704 2.3M 13 Mar 16:12 All_Metadata.csv I was just curious as to what the @ symbol means? I presumed it's a file attribute but I googled it and couldn't find any reference to it.

Unix extract .zip file in hdfs

I want to unzip a .zip file present in hdfs and store the output in hdfs. I tried below command hadoop fs -text testData/sample/slarge.zip | hadoop fs -put - testData/sample1/uncompressed-file.txt, but it is not working properly and getting garbage result in output result. Is there any way to do unzip file in hdfs? Note: the file is a .zip file not .gzip file.

Unix Check if a file exists in artifactory before downloading it shell using curl/wget from jenkins

This is a common question, somehow I am not able to get it working for me. I have an artifactory folder where in I store json files. On jenkins I am supposed to download one of the jsons e.g. Myfile.json. But this has to be done only if the file exists. Tried using below approaches: Approach: 1) url="https://abc/folder/Myfile.json" if curl --output /dev/null --silent --fail -r 0-0 "$url"; then echo "URL exists: $url" else echo "URL does not exist: $url" fi Problem: It keeps on entering th

Unix How to use dd on WSL?

How can I used the dd command to dump the contents of a removable disk in WSL? When I run, dd if=/mnt/d of=sdDump bs=512 count=1 I get the error dd: error reading '/mnt/d': Is a directory I followed the steps shown here to mount the disk: sudo mkdir /mnt/d sudo mount -t drvfs D: /mnt/d Doing this allows me to see the files on the disk via ls, but running dd yields the above error.

Unix Run script on particular day without crontab

I am having a driving script which calls internally multiple scripts. `sh main_script.sh > main_script.log` inside main_script.sh sh -x script_1.sh sh -x script_2.sh sh -x script_3.sh I Have to run the internal scripts in particular dates and manage failure scenarios accordingly, If any of the script fails then while retrying it should run only that particular sub script. script_1.sh - 25th of every month script_2.sh - daily script_3.sh - Every quarterly month end

At the Unix prompt, how do you pull a variable number of lines (which may include a blank line) from a file matching a pattern?

My file has multiple messages in it, each with a time stamp. I need to pull out just one message from a file based on its timestamp. Sometimes a message will have a blank line within the contents of the message. I prefer to do this at the unix prompt on an AIX operating system. My file (er96aa.example) contains the following information. I want to pull out the second message with a time stamp of 15:56:10.097 (it should be a total of 4 lines of data). 07/05/19 15:56:10.091 SOCKETSND MESSAGE LEN

UNIX config file issue

An issue I'm having is trying to update values in the configuration file using VI. So change the value in the lines according to a matched pattern. For example, with a configuration file as below (continuing till infinity with no line numbers)....how would I append an # to all lines with string abc in them? i.e. line 1 and 3. I'm trying :$s/abc/^/#/g with no luck. I'd like to comment out both 1 and 3 basiscally. Appreciate any thoughts on this. 1 abc xyz 2 def odc 3 abc nui 4 ghi rud

Unix Merge two files based on two common columns, and replace the blank to 0

I really need your help to merge two files (with 3 columns) based on $1$2 and get all values of $3 and replace the empty/blank with 0. Thank very much in advance file1: chr1 1000001 135 chr2 1000002 57 chr2 4400002 117 chr6 1000003 172 file2: chr1 1000001 377 chr1 5500002 320 chr6 1000003 432 Desired output: chr1 1000001 135 377 chr1 5500002 0 320 chr2 1000002 57 0 chr2 4400002 117 0 chr6 1000003 172 432 I have tried awk -F'\t' 'NR==FNR{A[$1

  1    2   3   4   5   6  ... 下一页 最后一页 共 41 页