LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-20-2012, 09:24 AM   #1
Ajit Gunge
Member
 
Registered: Jan 2008
Location: Pune
Distribution: RHEL,fedora
Posts: 253
Blog Entries: 1

Rep: Reputation: 21
Question Need help with writing a c shell script?


Hi All,
I want to write a C/perl shell script but I am not sure exactly to go about writing it.This is what how I can expalin you what the script should exactly do.You need not tell me the code but just point me in the direction and tell me the commands that I can use

I have a directory structure where actually the code resides.different file types are in different folders.The basic idea is as follows
When I run the script it should tar the files in the folder them.
Then it should ftp the file to an ip address that I give in a command then it should untar the file in a particular directory structure that is similar to the one that I have tared the file.this I should ideally be able to do in a single shell script.
Please let me know how I can go about writing the script.

Thanks for all your inputs.

Last edited by Ajit Gunge; 06-20-2012 at 09:31 AM.
 
Old 06-20-2012, 10:42 AM   #2
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
Terminology:
A "shell script" is normally written in the language of the shell. Otherwise you'll simply be writing a "Perl Script"---etc.

As for "C script"--I don't know what that would be---unless it were a shell script running in the "C Shell"


to write the actual script, start by trying all the individual commands. The first thing that jumps out at me is I am not sure that "tar" is available in the ftp protocol. (Uncle Google will know.....)

Next, if you start an ftp client during your script, then you need a way of passing ftp commands to ftp---I assume it's possible, but I've never seen the procedure.
 
Old 06-20-2012, 10:53 AM   #3
Ajit Gunge
Member
 
Registered: Jan 2008
Location: Pune
Distribution: RHEL,fedora
Posts: 253

Original Poster
Blog Entries: 1

Rep: Reputation: 21
Thanks Pixellany.That should get me started

I guess I will write the script in a perl.I want to pass my PWD output as a tar argument.Can you tell me how can I do that in perl.
I quick search in uncle google gave me this link.
 
Old 06-20-2012, 12:50 PM   #4
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
Quote:
I want to pass my PWD output as a tar argument.
Put the output of PWD into a variable, then expand the variable as part of the tar statement---use quoting rules as required.

Quote:
Can you tell me how can I do that in perl.
No

Why not just use BASH?----I don't know PERL, so I'm not really qualified to be asking you this......
 
Old 06-20-2012, 01:33 PM   #5
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 23,273

Rep: Reputation: 7696Reputation: 7696Reputation: 7696Reputation: 7696Reputation: 7696Reputation: 7696Reputation: 7696Reputation: 7696Reputation: 7696Reputation: 7696Reputation: 7696
probably a single rsync command will do this job, you only need to find out the flags you want to use.







__________________________________
Happy with solution ... mark as SOLVED
If someone helps you, or you approve of what's posted, click the "Add to Reputation" button, on the left of the post.
 
Old 06-21-2012, 01:58 AM   #6
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,415

Rep: Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785
For Perl see http://perldoc.perl.org/ & http://www.perlmonks.org/?node=Tutorials, but ftp doesn't support non-ftp cmds like tar.
If you want to do it all in one 'script' then use eg Perl and scp it instead.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
writing a shell script icecubeflower Linux - Newbie 1 03-29-2009 02:16 PM
Help writing a shell script! smoothdogg00 Programming 5 04-26-2006 12:15 PM
writing a shell script tchoua Linux - General 8 02-24-2005 07:18 PM
help writing shell script np complete Linux - Newbie 6 08-30-2004 10:43 PM
Need Help in Writing a Shell Script. KptnKrill Linux - General 2 05-19-2003 06:44 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:51 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration