Programming :: Bash-shell-like Less Functionality In The Python Shell?

Jun 25, 2010

Is there some type of functional way to read things in the Python shell interpreter similar to less or more in the bash (and other) command line shells?

Example:

Code:

>>> import subprocess
>>> help(subprocess)
...
[pages of stuff to read]
...

I'm hoping so as I hate scrolling and love how less works with simple keystrokes for page-up/page-down/searching etc.

View 4 Replies


ADVERTISEMENT

General :: Write Either PYTHON Or Bash Shell Scripting?

Jun 4, 2010

I do not know how to write either PYTHON or Bash Shell Scripting. I am to learn one for Linux Administration purpose. Which one will you recommend for a Linux Admin/Eng environment?

View 4 Replies View Related

Programming :: Run Shell Scripts Wrapped In Python?

Jul 11, 2010

I'm a new programmer (a life-long desire, but at 40 just getting to it) and cutting my teeth with Python. I just found the popen2 module today. I was so excited because I could do this:

Code:

>>> from popen2 import popen3
>>> cmd ="""TEXT="Hello, World!"
... echo $TEXT"""
>>> std_out, std_in, std_err = popen3(cmd)

[code].....

If you want to use another shell, substitute that shell for /bin/bash (e.g., /bin/sh for the shell portability purists out there). It is easy to modify what is returned as well. Don't like the tuple? Then just change it to return or even print stdout if you like.

View 14 Replies View Related

Fedora :: Stuck With Bash Shell / Changing Default Shell To Tcsh?

Mar 14, 2010

I want to change my default shell to tcsh. I used

Code:
usermod -s /bin/tcsh username
command as given at url

But if I open a new shell, it is still a bash shell.

How do I make my default shell as tcsh?

View 6 Replies View Related

Software :: IDE For Bash / Shell Programming

Mar 24, 2010

I just wanna ask if there's a ide for bash/shell programming?

View 2 Replies View Related

Programming :: Three Scripts - Using Bash As Shell

Feb 9, 2010

I am looking for three scripts (using bash as shell): to print out a list only with directories (no files) that they are found in running directory (no in subdirectories) to print out a list only with files (no directories) that they are bigger than 10Kb and are found in running directory (and in subdirectories) to print in the screen the lines of file with accidental order.

View 13 Replies View Related

Programming :: Difference Between Shell And Bash Scripts?

Sep 25, 2010

Whats the difference, and when do you use which?

View 2 Replies View Related

Programming :: Bash Shell Script Arithmetic??

Nov 10, 2010

I have four files that contain numbers that I grep for in a variable#!/bin/bashcat FILENAME`date +%y%m%d*.tot` | grep Grand | awk '{print $4}'

#output is
12
67

[code]...

View 6 Replies View Related

Programming :: Difference Between Formats In BASH Shell

Apr 30, 2009

I searched around but I can't get a good handle on the difference between the following formats in BASH shell.

$VAR
$(VAR)
$((VAR))
$($VAR)
$(($VAR))

Can someone explain it, or point to a clear, concise document explaining it?

View 3 Replies View Related

Programming :: Shell Scripting / Create A Shell Script Similar To Ls?

Jun 5, 2011

I am trying to create a shell script similar to ls, but which only lists directories. I have the first half working (no argument version), but trying to make it accept an argument, I am failing. My logic is sound I think, but I'm missing something on the syntax.

Code:
if [ $# -eq 0 ] ; then
d=`pwd`
for i in * ; do
if test -d $d/$i ; then
echo "$i:"
code....

View 10 Replies View Related

Programming :: Combining Commands And Var's In Bash Shell Script?

Jan 5, 2011

I have a command which on the command line needs to look like this

rlam -if3 '!pvalue -H image1.jpg' > image2.jpg

Nevermind what rlam or pvalue do ... they are part of a program package I am using. The above command works on the command line, and also when written verbatim in a bash shell script.

My problem is: in the script I wish to replace image1.jpg with the content of a variable, e.g.

IM1=image1.jpg

How to I get the script to insert the value of $IM into the command when the pvalue part of it needs to be quoted?

View 1 Replies View Related

Programming :: BASH Shell Differences: Login Or Interactive

Feb 18, 2011

Intuitively I think that the Login Shell and the Interactive Shell are the same applications but have access to different environmental variables.It this true? Why is there more than one type of shell anyways? You can change users with the interactive shell, why not log on with it to?

View 10 Replies View Related

Programming :: Loops In Bash Shell Or Variable Math?

Oct 28, 2010

I am trying to map the coordinates of a grid.

Code:

R=7 # number of rows (lines)
C=6 # number of columns
X=200 # initial horizontal location
Y=100 # initial vertical location

[code]....

View 4 Replies View Related

Programming :: Creating Array From Command Output (Bash Shell Script)

Jan 26, 2011

I have a command that outputs n lines of text, and I want to place each line into an array element, but I can't seem to get the syntax correct

So my command is this:
cat $configfile | sed -n '/cluster:'$clustername'/,/cluster/ p' | awk /host/

Which produces many lines depending on the value of $clustername. I'd like to get each line as elements of an array.

View 5 Replies View Related

Programming :: Writing Shell Snip To Import CSV Data Into Bash Array

Jan 5, 2011

I have been trying to write a simple snip of bash shell code to import from 1 to 100 records into a Bash array.

I have a CSV file that is structured like:
record1,item1,item2,item3,item4
record2,item1,item2,item3,item4
record3,item1,item2,item3,item4
record4,item1,item2,item3,item4

And would like to get this data into corresponding arrays as such:
$record1[item1-4]
$record2[item1-4]
$record3[item1-4]
$record4[item1-4]

View 9 Replies View Related

Programming :: Run Small Shell Script - Bash - Syntax Error Near Unexpected Token `('

Jul 9, 2010

I was trying to run small shell script, but could not run. I got the error like in subject.

This is exact way i was trying to do.

View 6 Replies View Related

Programming :: Global Bash Shell Functions - A.sh: Line 2: Echotm: Command Not Found

Sep 13, 2010

I wonder if there is anyway to make a user-defined bash shell function global, meaning the function can be use in any bash shell scripts, interactively or not. This is what I attempted:

Code:

$ tail -n 3 /etc/bashrc
echotm () {
echo "[`date`] $@"
}

[code]....

View 11 Replies View Related

Programming :: Perl About System Command / Fails If The Standard Shell Is Dash And Not Bash?

Jun 30, 2011

I am trying to fix a perl script, and I really suck at perl. But I think this problem will be easy for people who know it.

The problem is, I have an old setup script someone wrote many years ago. It fails if the standard shell is dash and not bash. The only way I've gotten it to work is to point /bin/sh to bash. I looked thru the script and it uses "system" many places, and I think that's the problem.

I searched for it and found this link:url

My plan is to include this function:

Code:
sub system_bash {
my @args = ( "bash", "-c", shift );
system(@args);
}
Then I could simply change all calls to system into system_bash and it should work?

The parameter to the system calls is usually some variable. What if the parameter is a list already? Do I need to test for it somehow, and if it's a list, prepend "bash" and "-c" to the list? How do I do that?

In the script there are lots of places like this:

my $error = system($cmd);
if ($error) {
die/warn "some error message";
}

Shouldn't there be a return in the system_bash function?

View 8 Replies View Related

Programming :: Bash Shell Read User Argument From Command Line And Test It

Aug 29, 2010

Trying to create a small script that will read user's input, test if user entered some input and if not display some message or display a text using user's input.

The script is the following but i get an error saying "[: 6: =: argument expected"

View 12 Replies View Related

Programming :: Invoke Java From Bash Terminal Via Shell Script Fails Under Mint Debian / Fix It?

Feb 16, 2011

I am running a Java application on the command line bash terminal under Mint Debian. I have JDK1.6.0_22 installed 64-bit, and the OS is 64-bit too. I have a few JAR files in the directory and a few native LWJGL libraries. When I run the application using the command line, all works fine.
Lets assume my directory where the files are is called /home/riz/MyGame. I change to that directory and this is the command I use code...

View 3 Replies View Related

Programming :: Convert Python Script To Shell Script?

Aug 28, 2010

I have a python script that i want to convert to shell for a specific reason. The converted script should also be able to accept a command line arg such as hostname, which the current python script doesn't.

View 13 Replies View Related

Programming :: Prevent "leak" Into Shell From A Customized Shell Menu Script?

Dec 15, 2009

I've created a simple script based menu. This menu will be accessed by only a certain users via ssh.When user logs in, the menu will automatically run. (configured at user's .bash_profile).How do I force the session to close when user hits Ctrl-C or Ctrl-Break ?In a nutshell, I don't want user to have access to shell.

View 11 Replies View Related

Ubuntu :: Get A Python Shell And Idle?

Dec 23, 2010

how do i get a python shell and idle on Ubuntu? so i can start learning how to write codes.

View 1 Replies View Related

Programming :: Bash Shell Script Read File Word By Word?

Jan 21, 2011

I have a output file look like this:
{"test1" : "test2", "test3" : "test4"},

How can I read word by word in each line?This is not working code:

a=0
while read word
do a=$(($a+1));

[code]...

View 14 Replies View Related

Programming :: Bash Shell Scripting / Using The Sort Command To Sort The Top 5 CPU Processes?

Feb 28, 2010

What options should I use when I'm using the sort command to sort the top 5 CPU processes (ps -eo user,pid,ppid,%cpu,%mem,fname | sort ??? | head -5) showing max to min usage?

View 2 Replies View Related

General :: Write A Shell Script Contains Python One?

Oct 22, 2010

I want to write a shell script contains python one. So,the result of python one is flv file. I want the path of this is copied into a enviroment variable that i have to pass as a flag argument of another program (to convert into mp3). To individuate the result of python script I thought to use (in PWD)

Code:
ls | grep -E '^.*mp3$'
But my question is: How can I copy this result into enviroment variable?

View 4 Replies View Related

Programming :: How To Turn Non-interactive Shell Into Interactive Shell?

Feb 4, 2011

I have a situation where I am in a non-interactive shell. I have tried from within my non-interative shell to spawn an interactive shell but my output still does not goto me. Isn't there a way I can somehow go into /proc or somwhere and make the output my /dev/tty1? Or some way else to remedy this?The situation arises because I drop from my restricted shell environment (a sort of CLI interface), into the actual Linux shell. I cannot change the code of the CLI environment I am just faced with being in the linux shell environment and its non-interactive. Its very annoying to have to put > /dev/tty1 after every command I type.

Not to mention it seems damn near impossible to get pagers like more and less to work properly when your in a non-interactive shell.

View 2 Replies View Related

General :: $HOME/.bashrc Disabled When User Shell Is 'rbash' (restricted Shell)?

Jun 15, 2011

MACHINE: HP Proliant DL260G5OS: SLES 11 SP1kernel: Linux xserver 2.6.32.12-0.7-default #1 SMP 2010-05-20 11:14:20 +0200 x86_64 x86_64 x86_64 GNU/LinuxIt is used as remote xserver in a LAN.I have configured /usr/lib/restricted/bin/.rbashrc with some environment variables but when the users logon in the system finally is executed $HOME/.bashrc and some environment vars are overwritten.

View 2 Replies View Related

Ubuntu :: Does It Use Bash Or Some Other Shell

Sep 16, 2010

Does it use Bash or some other shell?

View 2 Replies View Related

Ubuntu :: Using 10.04-server 64bit AMD With Fluxbox - Matlab In A Shell The Shell Does Not Display Characters Anymore

Jul 26, 2010

I am using ubuntu10.04-server 64bit AMD with fluxbox. After I ran Matlab in a shell (without GUI) the shell does not display characters anymore, but will execute any command, I just can't see the characters that I'm typing.. I use aterm and xterm, does anybody know why that is, am I missing a package?

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved