Programming :: How To Create Own C Shell
Jul 11, 2010i got to build my own linux shell for my project
View 5 Repliesi got to build my own linux shell for my project
View 5 RepliesI 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....
How do I create a user account in a shell script? I know this may sound n00bish to you, but I know it's more than just mkdir-ing the home directory and subdirectories.
View 7 Replies View RelatedI came across this script a while back that i found. What i want to do is edit the script to create a default web page in /var/www/html a new user is added through the script.What the script does now is adds a user and sets a password for the user. What possible way (either through a combination of python or c or some other language) could i add to the shell script to do this? I've tried just dointhe command to touch index.html /var/www/html but it puts it on the desktop. Here's the script....
Code:
#!/bin/bash
# Script to add a user to Linux system
[code]...
I would like to develop a shell script that would automatically run a backup program and then shutdown the computers, but I do not know the first thing about script development or even writing scripting.
View 2 Replies View RelatedI have a shell script that need to create some files:
1) backup files of user passed in file ( that will be written by this shell ).
2) temp files that the shell will create and later delete/remove.
This shell script will be used from my local dir ( I am not a super or a sysadmin ). Users of this shell will call this script to run on their local files in their respective directories. When my script runs, it errors with the following:
cp: cannot create regular file `./listfile.txt.backup': Permission denied
/home/myUser/tools/myShellScript: line 12: listfile.txt: Permission denied
for the temp I was able to avoid this error by creating the temp file in the /tmp directory. All I want is for this shell script to run, create/modify/backup files in user's local dirs.
The user dir has the following permission:
drwxr-xr-x testDir
the file that needs to be backed-up has:
-rw-r--r-- listfile.txt.
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.
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 RelatedI decided to try and find a home inventory application. I found one called "Attic Manager" that works in Ubuntu. [URL]
The instructions are to run it from the terminal. That's ok for once and a while, but a pain if used regularly. So I tried to set up a launcher for it. I couldn't seem to get it to work. In the command, I simply put in the path and file name, but can't seem to get it to work.
I would like to create some aliases for bash shell. On other Unix/Linux machines I have done this using the alias command like this: alias rm rm -i
When I type that into a terminal on Ubuntu, it looks like alias is not installed. I get this:
bash: alias: rm: not found
bash: alias: rm: not found
bash: alias: -i: not found
I tried adding the alias to .bashrc instead, but then I get the same error message every time I start terminal. Just for fun I tried apt-get install alias, just to see what would happen, and it installed something called libperl-alias instead, and alias still doesn't work.
I would like to create the shell which would support the LS command in C++. And any way to change the command prompt.
View 1 Replies View RelatedI am a complete newbie to linux. I am currently taking a course at Devry university called netw240. I am in my 2nd week of class and am required to turn in a paper at the end of the coures were I write an automated shell script. I am currently using Fedora 12 on a Vmware player and want to try to write a script that automates the process of Logging user login activity to detect unauthorized remote access attempts.I am looking for pointers on were to start, examples, ect.. anything that can get me started. Also, is this type of script to much for a beginner?
View 11 Replies View RelatedI tried to create logfile for the below shell program but i was not able to get log file,can anyone help me for the below program to create a log file for the shellscript.
View 12 Replies View RelatedI recently started shell programming and my task now is to do a menu display.Currently i am stuck whereby user will input both title and author and it will delete it.
Do i have to use sed command?
how can I create a shell script for ssh where I don't have to type the password manually?I have learned expect command and I have tried multiple examples, but it didn't work.
View 7 Replies View RelatedI was planning on using my VPS to grant some of my friends shells. The problem though is that I don't want them doing crazy stuff on it, like using up all my RAM or disk space. I would like to limit them to a very small 25 mb disk space, and allow them only certain application in /usr/bin like python perl irssi screen etc. I do NOT want them to be able to cd out of their home directory. I really want this to be setup like the shell provider SHellium. I can setup the FTP and SSH stuff myself.
View 3 Replies View RelatedI am using Linux on my system. I don't have gui for my system, only console is there.
I have some task to create a menu box window using dialog in shell scripting.
I have to take input from user & save it in a file.
But this should like html form as e.g.
Name - .....................
email id - ..................
phone - ......................
location - ...................
Submit Cancel
Such window should be displayed on console using dialog & then user will enter his information there as Name,email id, phone,etc & submit it, then it gets saved to a file. Here submit & cancle are buttons. I have to do it in bash shell scripting. Or give me some examples like the above with shell script code.
I was trying to create a shell script which will automatically login to the server 192.168.1.7 and checks if a user exists there or not, if it doesn't exist then it should create the user.I have very little idea about shell scriptThis is what I tried:Quote:
#!/bin/bash
pass="sacharje"
ssh 192.168.1.7
Now, how to pass that password automatically to the ssh when it asks for the password? (I can't use public key authentication here)
I have Disk /dev/cciss/c0d1: 599.9 GB, unallocated on CentOS release 5.4 .
I need to create about 30-40 LVM's worth 500GB as raw devices for sybase . is there a way to script it or anyone already has it ?
The problem is that each time we need to do fdisk /dev/cciss/c0d1 and enter the partition no to create a new one .. how to overcome that problem and automate it in a script ?
Is it possible to assist in the programming Shell Scripts
Job:
To send a message to the email,All orders written in Terminal or ssh
example : ls , pwd , cat , and other
How do I create a launcher/shortcut on Gnome desktop, which starts a Terminal window and executes a shell script?The script should execute as if I started the script manually, i.e. if I abort the script by pressing CTRL + C, the script should terminate but the terminal window should remain on screen.If I create the shell script launcher/shortcut using the �straight forward �Create Launcher� method�, the terminal window also closes when I hit CTRL + C
View 8 Replies View RelatedI was wondering if there would be a way for me to copy the contents of a shared folder that's running on an XP system using shell script. Actually, there are two shared folders that I want to do this with. I want to be able to launch the script and automatically copy all the contents of each folder into two separate folders on my ubuntu desktop. For example;
Lets say that I have Shared Folders A1 and A2 on my networked XP system and I have Folders B1 and B2 on my Ubuntu desktop. I want the script to automatically copy the contents of A1 into B1 and likewise for A2 and B2. During the copying, I want the script set up such that any pre-existing files in the B1 & B2 folders will automatically get overwritten by the ones copied from A1 & A2.Is there any possibilities of me achieving this?
An external service I dont manage pushes mediafiles into a shared directory on my server. I need to move these files into their correct directories automatically. The problem is that if I run my script as a cronjob once every 3 minutes, I notice that the script copies files which are still on their way into my server. So I need to figure out how to have the script check that the files are complete (done downloading) before the script moves the files. This is what I got so far:
Code:
#!/bin/sh
# Script by proximity 280709.
# Locate correct directory
[code]....
how come I can create a shell script file with two functions, I can execute the file, but when running declare -f, the functions are not on memory, and when invoking the function bash returns invalid. In the other hand, I can copy & paste the two functions at the end of my /etc/bashrc file.... then I can called the function by name.... and the commands within that function run on my session. here is a print of all my bash packets:
[Code]....
Does Fedora has restrictions on shell scripting? I haven't touch bash in seven years, so if things have change on it I'm behind on it, and sorry for my ignorance.
is it possible to create a shell script that adds user and password in the passwd and smbpasswd?
View 3 Replies View RelatedI WANT TO CREATE A Qt application / shell script, that simply updates my facebook status.perhaps this would be poosible but i don't know how to implelment this actually.
View 2 Replies View RelatedI 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.
I have a shell script that I would like to log to stdout and also to a file.....much like using tee. I would like to, instead of calling the script and piping to tee...i would like for the script to tee itself.
View 4 Replies View RelatedI have been searching most of today and am stuck on getting a variable into an awk portion of my bash script. I have this working:
Code:
#!/bin/sh
SRC=/var/log/mail.log
DEST=/var/www/output/myFile.txt
VAR=userName@myDomain.tld
[code]....
Can awk take a shell variable? Or do I have to do something completely different?
I need to push out a file to a bunch of linux and solaris boxes so I was hoping to use a script to automate the process with scp (or something else / better) - how can I batchmode scp so that it will do this? I should mention the servers do have keys set up so I do not have to authenticate manually or through something like an expect script...
View 4 Replies View Related