shell

how to split a string in shell and get the last field

hi, suppose I have the string "1:2:3:4:5" and I want to get its last field ("5" in this case). how do I do that using Bash? I tried cut, but I don't know how to specify the last field with -f. ...

opening a file in aix

(AIX/ksh) i have a chinese file ...i cant able to open it in aix using cat fully...if i give cat then some contents are missing...and if i give cat -v it is giving wierd code....even i tried with while loop to read contents,but not working...with more command i can but i cant use more in shell scripting...so please shed some idea here......

PHP system() help no simple commands work

I am trying to run a shell from one of my controllers in a PHP codeigniter applications, I am trying to run the file /x/sh/xpay4.sh however I just get 127 returned to the screen, I can even use basic commands like ls or pwd can any suggest why this would be, I thought it might be safe_mode when I ini_get('safe_mode') it returns 1 ...

Win7 Drag&Drop: Possible to find out if COleDataObject contains shell library?

I have an application with a file and folder list control which supports Drag&Drop operations. Now I would like to make it possible for the user to be able to drop a Windows 7 Library (e.g. Music, Pictures and so on) into this control. In my drop handler I have a COleDataObject and now I'm trying to find out, if a library has been dropp...

redirect COPY of stdout to log file from within bash script itself

I know how to redirect stdout to a file: exec > foo.log echo test this will put the 'test' into the foo.log file. Now I want to redirect the output into the log file AND keep it on stdout i.e. it can be done trivially from outside the script: script | tee foo.log but I want to do it from the inside I tried exec | tee foo.log ...

Blue Input Screen (Shell Script)

Hi, In Ubuntu Server 10.04 Sometimes when i'm installing some packages through apt-get, it prompts me with a blue dialog and asks for input/selection.. E.G: when installing mysql-server, it prompts me for a root password.. How can i accomplish this in my own shell script, so that same blue dialog will show up when i need to ask yes/no ...

Bash script to prepend a random number to all files

I have a "smart" phone that doesn't seem to have a music shuffle function, so the next best thing is to write a bash script to prepend all filenames in the current directory with a random number. Is this difficult to do? Thanks. ...

php safe_mode_exec_dir help

I am hoping to find some more information about this PHP setting, I assume I need to change its value in the php.ini but I set the root the folder as /file/path/ or as http://www.domain.com/file/path? Any advice would be great ...

error /usr/local/bin/perl: Argument list too long

Hello guys ive executed this command to delete malwarm from all my websites files and keep backup from each files but after 1 mint from executing got error /usr/local/bin/perl: Argument list too long Can anyone suggest a way to avoid this error , PS ive a huge a mount of files :) perl -e "s/<script.*PaBUTyjaZYg.*script>//g;" -pi.sa...

How to execute UNIX command from Windows XP system using ANT

I want to execute a UNIX command from my local Windows XP system using ANT script. UNIX system is a remote server. I have tried the following: <target name="execute" > <sshexec host="host IP" username="uname" password="pass" commandResource="sh abc.sh"/> </target> but got the error below: BUILD FAILED ..\bui...

CTRL-C doesn't work on Java program

Hi People, I found a weird scenario where if I start a java program and I want to exit gracefully with CTRL-C it doesn't work/respond, I have to do a CTRL-Z on the program and this is not cool, doing a ps lists the process... Anyone please. ...

Korn Shell: Variable assigned "000010" converted to 8 instead of 10.

I have a fixed length string which is a number. When I assign the string to a variable it is getting assigned 8 instead of 10. Why? How do I stop it? $ i=10 $ ((i=i+1)) $ echo $i 11 # Right answer $ i=000010 $ ((i=i+1)) $ echo $i 9 # Wrong answer Update: The answers confirm that the number is being converted to octal and that t...

How to create a user in linux using python

How do I create a user in Linux using Python? I mean, I know about the subprocess module and thought about calling 'adduser' and passing all the parameters at once, but the 'adduser' command asks some questions like password, full name, phone and stuff. How would I answer this questions using subprocess? I've seen module called pexpe...

In bash, how could I add integers with leading zeroes and maintain a specified buffer.

For example, I want to count from 001 to 100. Meaning the zero buffer would start off with 2, 1, then eventually 0 when it reaches 100 or more. ex: 001 002 ... 010 011 ... 098 099 100 I could do this if the numbers had a predefined number of zeroes with printf "%02d" $i. But that's static and not dynamic and would not work in my exampl...

what are shell built-in commands in linux?

Hi, I have just started using Linux and I am curious how are shell built-in commands such as "cd" defined. Also, if someone could please explain how it is implemented and executed? Thanks, Manjari ...

Unix Grep command

I have to search from codebase of lines having following pattern: "get_token , get_token" For example the below line 'type' should be listed: fn1(string.get_token(), string1.get_token()); Thanks in advance ...

Arguments to ssh in loop

I am trying to pass login details to different machines through ssh in a shell script. Even though I have used a for loop, I am ending up sending all the login information to all the machines. Can someone please help me with this? for system in ${allSystems} do machine=`echo $system | awk -F ";" '{print $1}'` use...

Get position of icons in any folder

Hello guys, I would like to get the coordinates of the icons in a specific folder. I have searched a shell method which does that, but I did not find any. someone can reference me or tell me what I should start looking for? (To the desktop I know how to do it, but to other folders I do not). Thanks, Aviad S. ...

How to extract a page title

Hey, I am trying to extract the page title from an HTML page cat index.html | grep -i "title>"| sed 's/<title>/ /i'| sed 's/<\/title>/ /i' The problem happens when some pages are written in one line! (believe me it happens) How do I solve that? Thanks! ...

Control a shell program through command line, giving it multiple instructions/data

I need to control a program in c++ (windows), I need to call it, then pass data to it as I collect it, finally after a certain command that program will use that data. I need to open the prog.exe and then line by line or value by value supply it information, it works manually through cmd. I have tried system() but this will stop after ...